note 83586 added to function.PDOStatement-rowCount

From: Date: Tue, 03 Jun 2008 10:19:27 +0000
Subject: note 83586 added to function.PDOStatement-rowCount
Groups: php.notes 
Request: Send a blank email to php-notes+get-140081@lists.php.net to get a copy of this message
It'd better to use SQL_CALC_FOUND_ROWS, if you only use MySQL. It has many advantages as you could retrieve only part of result set (via LIMIT) but still get the total row count. code: <?php $db = new PDO(DSN...); $db->setAttribute(array(PDO::MYSQL_USE_BUFFERED_QUERY=>TRUE)); $rs = $db->query('SELECT SQL_CALC_FOUND_ROWS * FROM table LIMIT 5,15'); $rs1 = $db->query('SELECT FOUND_ROWS()'); $rowCount = (int) $rs1->fetchColumn(); ?> ---- Server IP: 217.160.250.20 Probable Submitter: 210.245.51.121 ---- Manual Page -- http://www.php.net/manual/en/function.PDOStatement-rowCount.php Edit -- https://master.php.net/note/edit/83586 Del: integrated -- https://master.php.net/note/delete/83586/integrated Del: useless -- https://master.php.net/note/delete/83586/useless Del: bad code -- https://master.php.net/note/delete/83586/bad+code Del: spam -- https://master.php.net/note/delete/83586/spam Del: non-english -- https://master.php.net/note/delete/83586/non-english Del: in docs -- https://master.php.net/note/delete/83586/in+docs Del: other reasons-- https://master.php.net/note/delete/83586 Reject -- https://master.php.net/note/reject/83586 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140081) next »