[Typo3] class.t3lib_db.php and CONCAT

Karsten Dambekalns karsten at typo3.org
Fri Apr 8 11:16:13 CEST 2005


Hi.

The clean way would be to use || as this is SQL standard. It works in DB2,
Oracle and PostgreSQL. It works in MySQL *if* you use ANSI mode. It does
not work min SQL Server - who would have guessed that?

Since requiring the users to switch MySQL to ANSI mode might not be
feasible, read on.

media.res | alex widschwendter wrote:
>> If yes: Is there a workaround that will keep my code "DBAL compatible"?

Not really. AT least not cleanly exposed in DBAL.

> afaik the typo3 dbal uses the adodb libaries. for adodb there is
> function concat (http://phplens.com/lens/adodb/docs-adodb.htm#concat)
> which abstracts the function for different databases. maybe you can
> figure out if you can use this somehow, our karsten can give some
> feedback on this matter!?

This would of course be a possibility. Since DBAL now depends on the ADOdb
extension by Robert Lemke, you could even do this relatively safe - depend
on the adodb ext, and use the concat from there. But for this you'd have to
find out which database is being used, since you would not be using DBAL
all the time.

The best way is probably to check for DBAL being present with
t3lib_extMgm::isLoaded('dbal') and then decide whether to use CONCAT() for
MySQL or use ADOdb to build a portable concatenation operator. You'd have
to fetch the connection object from the global DB instance, this isn't all
too clean, but...

Hope this helps,
Karsten
-- 
Karsten Dambekalns
TYPO3 Association - Active Member
http://association.typo3.org/



More information about the TYPO3-english mailing list