note 63226 added to function.ibase-fetch-row

From: Date: Thu, 16 Mar 2006 14:06:18 +0000
Subject: note 63226 added to function.ibase-fetch-row
Groups: php.notes 
Request: Send a blank email to php-notes+get-105926@lists.php.net to get a copy of this message
If you have a query "select ... from table1 where ..." and would like to know the cardinality of the result set by issuing a separate query "select count(*) from table1 where ..." then you might end up with an incorrect value since an insert or delete can occur between the running of these queries (unlikely, but possible). The only way i can think of getting the correct value would be something along the lines of <?php $qry = "select ... from table1 where ..."; $result = ibase_query($tr, $qry) // assume $tr is a transaction $count = 0; while ($row[$count] = ibase_fetch_assoc($result)) $count++; ?> then $count is the cardinality, and $row the result set. Then you can work with the result set: <?php for ($i = 0; $i < $count; $i++) { // do something with $row[$i] } ?> ---- Server IP: 66.163.161.117 Probable Submitter: 165.165.123.97 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.ibase-fetch-row.php Edit -- http://master.php.net/note/edit/63226 Del: integrated -- http://master.php.net/note/delete/63226/integrated Del: useless -- http://master.php.net/note/delete/63226/useless Del: bad code -- http://master.php.net/note/delete/63226/bad+code Del: spam -- http://master.php.net/note/delete/63226/spam Del: non-english -- http://master.php.net/note/delete/63226/non-english Del: in docs -- http://master.php.net/note/delete/63226/in+docs Del: other reasons-- http://master.php.net/note/delete/63226 Reject -- http://master.php.net/note/reject/63226 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105926) next »