note 106640 added to mysqli-stmt.data-seek

From: Date: Wed, 23 Nov 2011 23:25:40 +0000
Subject: note 106640 added to mysqli-stmt.data-seek
Groups: php.notes 
Request: Send a blank email to php-notes+get-184645@lists.php.net to get a copy of this message
Although the documentation says you must provide a number between 0 and count - 1, you can actually supply a negative number, which appears to be cast to positive (such as in abs()). For example: <?php $db = new mysqli('localhost', 'test', 'password', 'schema'); $db->multi_query(" SELECT * FROM ( SELECT 1 as 'position' UNION SELECT 2 as 'position' UNION SELECT 3 as 'position' UNION SELECT 4 as 'position' UNION SELECT 5 as 'position' ) as rows"); $result = $db->store_result(); for ($i = 0; $i < $result->num_rows; $i++) { $offset = $i; $result->data_seek($offset); var_dump("Seek offset is: {$offset}", $result->fetch_object()); } for ($i = 0; $i < $result->num_rows; $i++) { $offset = -$i; $result->data_seek($offset); var_dump("Seek offset is: {$offset}", $result->fetch_object()); } ---- Server IP: 208.69.120.55 Probable Submitter: 24.234.146.230 ---- Manual Page -- http://www.php.net/manual/en/mysqli-stmt.data-seek.php Edit -- https://master.php.net/note/edit/106640 Del: integrated -- https://master.php.net/note/delete/106640/integrated Del: useless -- https://master.php.net/note/delete/106640/useless Del: bad code -- https://master.php.net/note/delete/106640/bad+code Del: spam -- https://master.php.net/note/delete/106640/spam Del: non-english -- https://master.php.net/note/delete/106640/non-english Del: in docs -- https://master.php.net/note/delete/106640/in+docs Del: other reasons-- https://master.php.net/note/delete/106640 Reject -- https://master.php.net/note/reject/106640 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184645) next »