Jump to content

Zend_Db_Table query creation...


ajlisowski

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.