How to use zend paginate with normal sql query rather than zend_db_select
so basically you can use zend
paginate via the following:
$sql = new Zend_Db_Select($db);
$sql->from(table);
$sql->where(zend_db_select_sucks = 1);
$paginator = Zend_Paginator::factory($sql);
is there a way to use paginator such that you can 开发者_如何学Cset $sql
yourself without using zend_db_select
so just
$sql = "SELECT * FROM table WHERE zend_db_select_sucks = 1"
$paginator = Zend_Paginator::factory($sql);
?
Isn't the point of the Paginator factory that you can also pass it a rowset and it will paginate that too? I just tried this out and it seemed to work for me (even though I usually use Zend_Db_Select)
$db = Zend_Db_Table::getDefaultAdapter();
$rowset = $db->query('SELECT * FROM user')->fetchAll();
$paginator = Zend_Paginator::factory($rowset);
you have to wrap your SQL query string inside of query()
before passing it to anything else otherwise ZF doesn't know what you're telling it
$db = new Application_Model_DbTable_Example(); // if you've created a model for your db
$select = $db->query("SELECT * FROM table WHERE value='varstring'")->fetchAll;
and then you can send that off to paginator
精彩评论