Search code examples
phpzend-frameworkzend-dbzend-db-table

Zend_Db_Table_Select_Exception


Recieved this error from the below method?

2013-10-02T14:20:05+01:00 ERR (3): exception 'Zend_Db_Table_Select_Exception' with message 'Select query cannot join with another table' in /usr/share/php/Zend/Db/Table/Select.php:215

class Application_Model_DbTable_Provenir extends Zend_Db_Table_Abstract {
    protected $_name = 'provenir_instance_response';
    protected $_primary = 'provenir_response_id';
    protected $_sequence = true;

    /**
    * Get passed result and check ID
    * @param string $memId
    * @return Zend_Db_Table
    */
    public function scoreCardQuery($memId){
        //Build Query
        $select = $this->select();
        $select->from('scorecard_results', array('passed', 'check_id'));
        $select->where('traveller_id=?', $memId);
        return $this->fetchAll($select);
    }
}

There is no join there? :S

Is it because I am referencing provenir_instance_response as the DB table in the class argument butI am trying select from scorecard_results?


Solution

  • /**
     * Get passed result and check ID
     * @param string $memId
     * @return Zend_Db_Table
     */
    public function scoreCardQuery($memId){
        //Build Query
        $select = $this->select();
        $select->setIntegrityCheck(false); //Must be set for this query to work
        $select->from('scorecard_results', array('passed', 'check_id'));
        $select->where('traveller_id=?', $memId);
        return $this->fetchAll($select);
    }