You are here

function DB_common::quoteIdentifier in Flickr API 5

Quotes a string so it can be safely used as a table or column name

Delimiting style depends on which database driver is being used.

NOTE: just because you CAN use delimited identifiers doesn't mean you SHOULD use them. In general, they end up causing way more problems than they solve.

Portability is broken by using the following characters inside delimited identifiers: + backtick (<kbd>`</kbd>) -- due to MySQL + double quote (<kbd>"</kbd>) -- due to Oracle + brackets (<kbd>[</kbd> or <kbd>]</kbd>) -- due to Access

Delimited identifiers are known to generally work correctly under the following drivers: + mssql + mysql + mysqli + oci8 + odbc(access) + odbc(db2) + pgsql + sqlite + sybase (must execute <kbd>set quoted_identifier on</kbd> sometime prior to use)

InterBase doesn't seem to be able to use delimited identifiers via PHP 4. They work fine under PHP 5.

@since Method available since Release 1.6.0

Parameters

string $str the identifier name to be quoted:

Return value

string the quoted identifier

1 method overrides DB_common::quoteIdentifier()
DB_mysql::quoteIdentifier in phpFlickr/PEAR/DB/mysql.php
Quotes a string so it can be safely used as a table or column name

File

phpFlickr/PEAR/DB/common.php, line 315

Class

DB_common
DB_common is the base class from which each database driver class extends

Code

function quoteIdentifier($str) {
  return '"' . str_replace('"', '""', $str) . '"';
}