note 108059 deleted from function.db2-prepare by danbrown

From: Date: Thu, 10 May 2012 17:54:15 +0000
Subject: note 108059 deleted from function.db2-prepare by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187684@lists.php.net to get a copy of this message
Note Submitter: gjarrige at six-axe dot fr ---- I found a bug in the code I posted the 02-Mar-2012 at 04:20 for the scroll cursor technique : to correct it, delete the line with the variable $max_offset. For a better code : public static function getScrollCursor($db, $sql, $args, $offset, $nblines_by_page ) { if (!is_array($args)) { $args = array() ; } $offset = intval($offset) ; if ($offset <= 0) { $offset = 1 ; } $nbl_by_page = intval($nbl_by_page); if ($nbl_by_page <= 0) { $nbl_by_page = 10 ; } $rows = array() ; $st = db2_prepare ( $db, $sql, array('cursor' => DB2_SCROLLABLE) ); if (! $st) { // place your error message here $rows = null; } else { if (! db2_execute ( $st, $args )) { // place your error message here $rows = null; } else { for ( $tofetch = $nbl_par_page, $row = db2_fetch_assoc ( $st, $offset); $row !== false && $tofetch-- > 0; $row = db2_fetch_assoc ( $st ) ) { $rows [] = $row; } } db2_free_stmt($st); } return $rows ; }

« previous php.notes (#187684) next »