PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_DataObject » Bug #1935

Bugs when using config 'quote_identifiers = 1'

Details

Submitted2004-07-21 09:38 UTC
Fromxine at 163 dot com
Assignedalan_k
StatusClosed
PackageDB_DataObject
PHP Version4.3.0
OSLinux
Roadmaps(Not assigned)

Comments

[2004-07-21 09:38 UTC] xine at 163 dot com

Description:
------------
When Using 'quote_identifiers =1' to avoid table/column name conflict
with SQL keyword, here 2 bugs found.
@ method selectAs():
794 $s = '%s';
795 if (@$_DB_DATAOBJECT['CONFIG']['quote_identifiers']) {
796 $this->_connect();
797 $DB = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
798
799 $table = $DB->quoteIdentifier($table);
800 $s = $DB->quoteIdentifier($s);
801 $format = $DB->quoteIdentifier($format);
802 }
803 foreach ($from as $k) {
804 $this->selectAdd(sprintf("{$s}.{$s} as {$format}",$table,$k,$k));
805 }
at line 799/800 $table and $s are both quoted, line 804's result is that
the table name will be quoted twice.

@ mothod count():
1314 function count($countWhat = false,$whereAddOnly = false)
1315 {
1316 global $_DB_DATAOBJECT;
1317
1318 if (is_bool($countWhat)) {
1319 $whereAddOnly = $countWhat;
1320 }
1321
1322 $t = clone($this);
1323
1324 $quoteIdentifiers = @$_DB_DATAOBJECT['CONFIG']['quote_identifiers'];
1325 .........

Assume I make a new DB_DataObject insistant now then call the ->count() just follow this,
the valiable $quoteIdentifiers would be NULL, and the COUNT(*)-SQL generated later will not
be quoted.
Why? These where no _loadConfig() or _connect() or anything before to fetch the CONFIG.
Seems need to move line 1324 after a _connect() call.