How to resolve the Zend DB Select “Select query cannot join with another table” error

If you are coding in Zend Framework 1.X.X and writing a up a model which will return the records according to the request parameters provided then you may have come across the following error message

Select query cannot join with another table

This error happens when you are trying to join tables without specifying


So you can specify this as below

	public function getAllPartsStock()
		$select = $this->select()
						->join( array('mk'=>'make'), 'p.make_id =', array('mk.title as mkname'))						
						->join( array('md'=>'model'), 'p.model_id =', array('md.title as mdname'));
		$select = $select->order(" desc ");						   							
		$row = $this->fetchAll($select);	
		return $row->toArray();

As you can see this directive is applied just after the select() so Zend knows that it does not have to check for any constraints. The reason this is needed is that Zend checks all relevant tables whether integrity constraint is maintained or not. If its not maintained then it displays the error message as above.

More details on why this is needed can be found here.

0.00 avg. rating (0% score) - 0 votes

Leave a Reply

Your email address will not be published. Required fields are marked *