Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-15-2007, 07:16 AM
Junior Member
 
Join Date: Aug 2007
Posts: 1
Question Zend_db (about Paging, at MsSQL)

$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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:35 PM.