note 94687 added to function.db2-prepare

From: Date: Wed, 18 Nov 2009 15:52:40 +0000
Subject: note 94687 added to function.db2-prepare
Groups: php.notes 
Request: Send a blank email to php-notes+get-163036@lists.php.net to get a copy of this message
If you are having problems with scrollable cursors and the prepare statement, I've found that you cant set the scrollable option on the connection. The following code (which tries to get the 2nd record): <?php $sql = "SELECT * FROM SCHEMA.TABLENAME"; $options = array('cursor' => DB2_SCROLLABLE); $conn = db2_connect($database, $user, $password,$options); $stmt = db2_prepare($conn, $sql); $result = db2_execute($stmt); $row = db2_fetch_both($stmt, 2); $conn = db2_connect($database, $user, $password); $stmt = db2_prepare($conn, $sql, $options); $result = db2_execute($stmt); $row = db2_fetch_both($stmt, 2); ?> Will result in the following error: Warning: db2_fetch_both() [function.db2-fetch-both]: Fetch Failure in dbtest.php on line 7 In fact, even if you set the options on both the connection and the prepare your fetch will not work. You must only set that option on the prepare. ---- Server IP: 192.41.40.227 Probable Submitter: 204.87.68.252 ---- Manual Page -- http://www.php.net/manual/en/function.db2-prepare.php Edit -- https://master.php.net/note/edit/94687 Del: integrated -- https://master.php.net/note/delete/94687/integrated Del: useless -- https://master.php.net/note/delete/94687/useless Del: bad code -- https://master.php.net/note/delete/94687/bad+code Del: spam -- https://master.php.net/note/delete/94687/spam Del: non-english -- https://master.php.net/note/delete/94687/non-english Del: in docs -- https://master.php.net/note/delete/94687/in+docs Del: other reasons-- https://master.php.net/note/delete/94687 Reject -- https://master.php.net/note/reject/94687 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163036) next »