Processing MySQL backlinks when switching DB modules using the PHP PDO interface

  • I am currently working on a PHP application that uses the MySQL database for its backend.
  • All my queries contain backlinks to avoid field names. This means that I can have fields like "password" in the request without any problems (see. Example)
  • I know that backreferences are not universal between relational database engines (e.g. SQLite uses a double quote)
  • All requests in my php application are done using the PHP PDO interface

My question is this: if I want to switch database engines, say, from MySQL to SQLite, what do I need to do to handle backlinks in all my queries? I really don't want to go through all my code and change / delete backlinks. Any suggestions? Am I doing something wrong or not as part of best practices?

Request example:

SELECT
   `username`,
   `password`,
   `email_address`
FROM
   `users`
WHERE
   `id` = '1'
+5
source share
3 answers

Actually, you passwordreally do not need to specify ... This is not even a reserved word: http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

IMHO, the best approach you can take:

  • Do not use reserved words in your identifiers.
  • ; 2- ( backtick)

, - ; - .

+4

, , . backticks, SQL Standard, . , . , , .

MySQL- (-) ANSI-QUOTES, MySQL , :

+4

Actually, SQLite is compatible with the citation type MySQL backtick.

However, the opposite is true if you follow @Frank's advice .

+1
source

All Articles