I want to select values from 2db.
image_db => id, image_adress, category, product_id;
product_db => id, name, price;
I want to select the images from a particular category and for each image the data of the product
what should i do?
this is correct?
$select = $image_model->select()
->where('category = ?',$category)->from(array('i'=>'image_db'),
array('adress','product_id'))->join(array('p'=>'product_db'), 'i.product_id'='p.id');
assuming they are both in same database, it seems to be correct, but i think you are using it from controller,
but you can use it from model which will be better hence zend is an MVC,
public function getProducts($category)
{
$sql=$this->select()
->setIntegrityCheck(false)
->from(array('i'=>'imagemaster'),array())
->join(array('p'=>'projectmaster'),'i.project_id=p.id',array())
->where('category = ?',$category)
->group('p.id');
$resultSet = $this->fetchAll($sql);
return $resultSet;
}
havent tested it but it should work.. hope it helps..