note 66351 modified in function.db2-exec by danbrown

From: Date: Tue, 15 Dec 2009 20:04:39 +0000
Subject: note 66351 modified in function.db2-exec by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164020@lists.php.net to get a copy of this message
If you need to "emulate" offset/limit (as PEAR::DB puts it) for db2 queries, you will definitely need to add array('cursor' => DB2_SCROLLABLE) to your db2_exec() call. Otherwise, you will get nothing useful from db2_fetch_{whatever}() when you try to (see following hack for example): <?php $limit = 10; $offset = 20; for ($i = 0; $i < $limit && $row = db2_fetch_array($result, $offset + $i); $i++) { // stuff goes here } ?> You can accomplish the same time of thing using sub-selects, "with" statements and other things new to me in the world of DB2, but the more dynamically generated the queries, the more difficult it gets to implement limit/offset behavior on the fly. --was-- If you need to "emulate" offset/limit (as PEAR::DB puts it) for db2 queries, you will definitely need to add array('cursor' => DB2_SCROLLABLE) to your db2_exec() call. Otherwise, you will get nothing useful from db2_fetch_{whatever}() when you try to (see following hack for example): $limit = 10; $offset = 20; for ($i = 0; $i < $limit && $row = db2_fetch_array($result, $offset + $i); $i++) { // stuff goes here } You can accomplish the same time of thing using sub-selects, "with" statements and other things new to me in the world of DB2, but the more dynamically generated the queries, the more difficult it gets to implement limit/offset behavior on the fly. http://php.net/manual/en/function.db2-exec.php

« previous php.notes (#164020) next »