ajlisowski Posted June 21, 2010 Share Posted June 21, 2010 Hi all, I am trying to port a class I made to zend framework and use zend_db_table. The class basically allowed to quickly generate a table html object with correct data and pagination based on mysql information by passing tables, rows and filters to it. add_table($prefix, $table, $joined='') **joined would be the ON portion of the join, so if table a.id left joined table b.id the joined input would be 'a.`id`=b.`id` public function add_column($prefix, $column, $label) public function add_filter($item1, $relationship, $item2, $conjunction=" AND ") The class would then go through and create a string representing a select statement based on the data. So first it would loop through the columns and add the selected columns to the string. Quote Link to comment https://forums.phpfreaks.com/topic/205414-zend_db_table-query-creation/ Share on other sites More sharing options...
trq Posted June 21, 2010 Share Posted June 21, 2010 Cool. The problem? Quote Link to comment https://forums.phpfreaks.com/topic/205414-zend_db_table-query-creation/#findComment-1074980 Share on other sites More sharing options...
ajlisowski Posted June 21, 2010 Author Share Posted June 21, 2010 Oops, sorry, I copied my post after typing it out and left a bit out... Hi all, I am trying to port a class I made to zend framework and use zend_db_table. The class basically allowed to quickly generate a table html object with correct data and pagination based on mysql information by passing tables, rows and filters to it. add_table($prefix, $table, $joined='') **joined would be the ON portion of the join, so if table a.id left joined table b.id the joined input would be 'a.`id`=b.`id` public function add_column($prefix, $column, $label) public function add_filter($item1, $relationship, $item2, $conjunction=" AND ") The class would then go through and create a string representing a select statement based on the data. So first it would loop through the columns and add the selected columns to the string. It would then loop through the table array to add froms and joins. it would then loop through the filter array to create the filter statements, WHERE, AND, OR etc. Then depending on the page set and the total values per page it would create a limit statement at the end of the query. It would run the query and then create a table based on the resulting data. How would I go about creating and executing the query in zend_db_table? Im not even sure where to begin, so a general idea would help. Would I need to extend zend_db_table_abstract for each table in my database first? Or is it possible for me to dynamically create a new zend_db_table object then create the query through ->from, ->where, ->join etc? Any help would be extremely nice, as if I could get this class converted it would save me a lot of time and I would learn a lot about zend_db_table in the process. Quote Link to comment https://forums.phpfreaks.com/topic/205414-zend_db_table-query-creation/#findComment-1074986 Share on other sites More sharing options...
trq Posted June 21, 2010 Share Posted June 21, 2010 Nope. I still don't see any question in your post. Quote Link to comment https://forums.phpfreaks.com/topic/205414-zend_db_table-query-creation/#findComment-1074990 Share on other sites More sharing options...
ajlisowski Posted June 21, 2010 Author Share Posted June 21, 2010 Yeah...I couldnt edit the original post anymore, so I had to edit the reply. Didnt expect such quick responses Quote Link to comment https://forums.phpfreaks.com/topic/205414-zend_db_table-query-creation/#findComment-1074991 Share on other sites More sharing options...
Cagecrawler Posted June 23, 2010 Share Posted June 23, 2010 Maybe you should look at using Zend_Db_Select as that sounds like what you're doing to get the data itself. Assuming you're using Zend_View, you can then use the partialLoop view helper to build your table. Quote Link to comment https://forums.phpfreaks.com/topic/205414-zend_db_table-query-creation/#findComment-1076209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.