|
|||
|
$db = Zend_Db::factory('Pdo_Mssql', $DB_CONFIG_Params);
$start = array_key_exists('start', $_GET) ? $_GET['start'] : "20"; $limit = array_key_exists('limit', $_GET) ? $_GET['limit'] : "5"; // Type A. (no use order) $select = $db->select(); $select->from('mytable', '*') ->limit($limit,$start); $sql = $select->__toString(); /* $sql = 'SELECT * FROM (SELECT TOP 5 * FROM (SELECT TOP 25 "mytable".* FROM "mytable" ) AS inner_tbl) AS outer_tbl'; It can not Paging. It always get top5 from "mytable". */ // Type B. ( use order) $select = $db->select(); $select->from('mytable', '*') ->order('id') ->limit($limit,$start); $sql = $select->__toString(); /* $sql = 'SELECT * FROM (SELECT TOP 5 * FROM (SELECT TOP 25 "mytable".* FROM "mytable" ORDER BY "id" ASC ) AS inner_tbl ORDER BY "id" DESC) AS outer_tbl ORDER BY "id" asc'; It can Paging. */ ----------------------------- but, at mySQL, Type A and B, they can Paging. Is it a bug? or I am a fool. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|