Question

I have this problem using Zend and I think its db related at all:

I have two tables, one contains:

id, ..., file, desc, date

and the second table contains:

id, ..., file_1, desc_1, file_2, desc_2, date

What I need as a result is:

id, ..., file, desc, date

From both tables, which means I need to have coresponding file, desc and file_1 ->file, desc_1->desc and file_2->file, desc_2->desc in this one table.

Any idea how to do this with Zend 1.12?

Was it helpful?

Solution

You need to use JOIN in Zend ORM

for exmaple

public function getPendingProjects($owner){

$data = $this   ->getAdapter()
                ->select()
                ->from('campaign' , array('title', 'id'))
                ->joinLeft('job', 'campaign.id = job.campaign_id', array('count(user_id)'))
                ->where('campaign.employer_id = ' . (int)$owner . ' AND job.status = 3' );

return $data->query()->fetchAll();

}

taked from here http://zend-frameworks.com/en/articles/zend_db_zend_mysql.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top