How to use zend paginate with regular sql query, not zend_db_select

so you can use zend paginate as follows:

 $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 so that you can set $sql yourself without using zend_db_select

therefore just

 $sql = "SELECT * FROM table WHERE zend_db_select_sucks = 1" $paginator = Zend_Paginator::factory($sql); 

?

+4
source share
2 answers

Is it a Paginator factory item that you can also pass a set of strings to it, and it will also paginate? I just tried this and it seemed to work for me (although I usually use Zend_Db_Select)

 $db = Zend_Db_Table::getDefaultAdapter(); $rowset = $db->query('SELECT * FROM user')->fetchAll(); $paginator = Zend_Paginator::factory($rowset); 
+7
source

you need to wrap the SQL query() string inside query() before passing it to anything else, otherwise ZF doesn't know what you're saying

 $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 this to a paginator

0
source

All Articles