ramu1081 / php-sql-parser

Automatically exported from code.google.com/p/php-sql-parser
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

SqlBuilder delimiter suggestion #119

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
If you build a select without putting in a delimiter, a notice is raised.

No notices to be raised, sql builder, I think, should be able to handle no 
delimiter set.

What version of the product are you using? On what operating system?
php-sql-parser-20140108.zip     Export from /tags/2014-01-08 
PHP 5.3.11, Linux, Centos 6

Please provide any additional information below.

I rectified this by changing the code in the class 

SelectBuilder

from:

protected function getDelimiter($parsed) {
return ($parsed['delim'] === false ? '' : (trim($parsed['delim']) . ' '));
}

to:
protected function getDelimiter($parsed) {
return (isset($parsed['delim']) || $parsed['delim'] === false ? '' : 
(trim($parsed['delim']) . ' '));
}

OR because I like objects:

protected function getDelimiter($parsed) {
        $parsed = (object)$parsed;
        return (!property_exists($parsed, 'delim') || $parsed->delim === false ? '' : (trim($parsed->delim) . ' '));
}

not too sure if this object conversion will work on all environments though as 
I've not tested it except in mine.

Original issue reported on code.google.com by parso...@googlemail.com on 31 Jan 2014 at 2:20

GoogleCodeExporter commented 9 years ago
Good point. I'll try to add the delimiter in all cases, till then, the code 
extension will help. I love objects too, but sometimes they are a little bit 
oversized. The isset() will do the job, I have added it to r1078. 

Original comment by pho...@gmx.de on 31 Jan 2014 at 8:59