[Typo3-dev] quoting SQL-identifiers
Rainer Kuhn
kuhn at punkt.de
Fri Apr 22 13:10:58 CEST 2005
Martin Kutschker wrote:
> It's possible to quote SQL-identifiers (eg table names) to avoid a clash
> with reserved names.
>
> It seems that ANSI-standard are " (double quotes). Mysql uses ` (back ticks)
> unless in ANSI mode (SET sql_mode='ANSI_QUOTES'). But you need 3.23.6 to get
> quoting at all.
I stumbled over this problem yesterday as I tried to convert an existing
extension using an "external" MySQL database to the TYPO3 DBAL. There is a
DB fieldname MATCH, and that's an reserved word in MySQL (SQL in general?).
In my exising non-DBAL code I used backticks to quote, but for DBAL I did
not found any hints what to do...
> How about other RDBMS'?
AFAIK for PostgreSQL it's " (double quotes).
> Question:
>
> Should we use identifier quoting in TYPO3 per default?
> How should this be accomplished?
>
> Possible soultion (if needed at all):
>
> t3lib_db->quoteIdentifier($ident)
>
> Opinons?
IMHO we should offer at least one DBAL method (as the one you suggested) to
use if needed. Furthermore I think it wouldn't be bad to use identifier
quoting in DBAL per default, this could prevent any probems.
Rainer
More information about the TYPO3-dev
mailing list