PHP Classes

Fatal error occurred

Recommend this page to a friend!

      SQL Parse Convert to Tree Array  >  All threads  >  Fatal error occurred  >  (Un) Subscribe thread alerts  
Subject:Fatal error occurred
Summary:Fatal error when parsing query "SELECT delete FROM foo"
Messages:4
Author:thijsdj
Date:2009-06-04 09:01:39
Update:2009-06-05 07:38:44
 

  1. Fatal error occurred   Reply   Report abuse  
Picture of thijsdj thijsdj - 2009-06-04 09:01:39
Hi,

I found another bug in your class. Using this query: "SELECT delete FROM foo"
I get the following error:
Fatal error: Unsupported operand types in .../dqml2tree.php on line 477

It seems like table fields with the name 'delete' are not supported.

I added some comments in the dqml2tree.php file, so the row numbers are not the original ones. Below you can find line 477 which is in function _makeInterTree().

476: if (count($new_branches) > 1 || substr($inter_rule_key, 0, 1) != '!') {
477: $_tree[$branch_rule] += $new_branches;
478: if (substr($inter_rule_key, 0, 1) == '!') break;

I'm using version 0.12.

Best regards,
Thijs

  2. Re: Fatal error occurred   Reply   Report abuse  
Picture of thijsdj thijsdj - 2009-06-04 10:04:27 - In reply to message 1 from thijsdj
Hi,

First of all, we're going to rename our columns called "delete". Because it's a bit awkward to have a column named "delete".

I also tried PEAR::SQL_Parser, and it has the same problem!

Maybe you could just document it that columns called "delete", "select", "insert" or "update" are not supported.

Also the query "SELECT something, delete FROM foo" works perfectly.

Keep up the good work.

Regards,
Thijs

  3. Re: Fatal error occurred   Reply   Report abuse  
Picture of François NEUMANN-RYSTOW François NEUMANN-RYSTOW - 2009-06-04 12:34:25 - In reply to message 1 from thijsdj
i put a
line

if (is_array($new_branches))



before line
$_tree[$branch_rule] += $new_branches;



and
line


if ($_tree['z'] > $_tree['a']) {

before line
$pos = strpos(substr($this->_sql, $_tree['_a'], $_tree['_z'] - $_tree['_a']), '(', 1);





the "normal" result has to be :
Array
(
[SQL] => Array
(
[_a] => 0
[_z] => 22
[SELECT] => Array
(
[FIELD] =>
)

[DELETE] => Array
(
[FROM] => Array
(
[TABLE] => foo
)

)

)

)

  4. Re: Fatal error occurred   Reply   Report abuse  
Picture of thijsdj thijsdj - 2009-06-05 07:38:44 - In reply to message 3 from François NEUMANN-RYSTOW
Thanks for the quick fix! It works perfectly.

Regards,
Thijs