FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=17136&edit=1

ID: 17136
Updated by: aharvey@php.net
Reported By: sakai at d4k dot net
Summary: PostgreSQL Recursive SQL (or simply WITH Query)
doesn't work properly
-Status: Open
+Status: Closed
Type: Bug
Package: DB
Operating System: CentOS release 5.4
Package Version: 1.7.13
PHP Version: 5.1.6
-Assigned To:
+Assigned To: aharvey
-Roadmap Versions:
+Roadmap Versions: 1.7.14RC2
New Comment:

-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: aharvey
-Roadmap Versions:
+Roadmap Versions: 1.7.14RC2
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.




Previous Comments:
------------------------------------------------------------------------

[2010-02-19 09:40:03] sakai

Actually, I do NOT know if WITH sub-queries can be followed by main
queries other than SELECTs...

If UPDATE or things like that can be the main query, Fixing this problem
might not be simple as adding 'WITH' to Line 356 of DB/pgsql.php.

Thanks anyway for handling this.

------------------------------------------------------------------------

[2010-02-19 06:56:27] sakai

Description:
------------
Simply, DB/pgsql.php is not expecting WITH queries.
I suppose it's on Line 356 of DB/pgsql.php.


Test script:
---------------
//postgres=> SELECT * FROM tree ;
// id | parent
//----+--------
// 1 |
// 2 | 1
// 3 | 1
// 4 | 2
//(4 rows)

$ret = $db->getAll(
'WITH RECURSIVE r AS (SELECT * FROM tree WHERE id = 1 UNION ALL SELECT
tree.* FROM tree, r WHERE tree.parent = r.id)'
. ' SELECT * FROM r ORDER BY id'
);

var_dump($ret);

Expected result:
----------------
array(4) {
[0]=>
array(2) {
["id"]=>
string(1) "1"
["parent"]=>
NULL
}
[1]=>
array(2) {
["id"]=>
string(1) "2"
["parent"]=>
string(1) "1"
}
[2]=>
array(2) {
["id"]=>
string(1) "3"
["parent"]=>
string(1) "1"
}
[3]=>
array(2) {
["id"]=>
string(1) "4"
["parent"]=>
string(1) "2"
}
}


Actual result:
--------------
int(1)

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedDec 24, '10 at 6:09a
activeDec 24, '10 at 6:09a
posts1
users1
websitepear.php.net

1 user in discussion

Aharvey: 1 post

People

Translate

site design / logo © 2021 Grokbase