Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select query cannot join with another table - JOIN Zend Framework

An error occurred Application error Exception information:

Message: Select query cannot join with another table This is my code:

<?php

class Application_Model_DbTable_Seguimientos extends Zend_Db_Table_Abstract {

    protected $_name = 'Seguimientos';    
    public function buscarCaso($cod_beneficiario) {
        $consulta = $this->select()

        ->from(array('seg' => 'Seguimientos'))
        ->join(array('casos' => 'Asuntos_Estudiantiles'),
        'seg.cod_radicado = casos.codigo_radicado')
        ->where('casos.cod_beneficiario = ?', $cod_beneficiario);

        $query = $this->fetchAll($consulta)->toArray();
        return $query;
    }
}

I use Zend Framework 1 error

like image 347
Jhosman Avatar asked Jul 05 '14 21:07

Jhosman


1 Answers

<?php

class Application_Model_DbTable_Seguimientos extends Zend_Db_Table_Abstract {

    protected $_name = 'Seguimientos';

    public function buscarCaso($cod_beneficiario) {

        $consulta = $this->select()

        ->from(array('seg' => 'Seguimientos'))
        ->join(array('casos' => 'Asuntos_Estudiantiles'),
        'seg.cod_radicado = casos.codigo_radicado')
        ->where('casos.cod_beneficiario = ?', $cod_beneficiario)
        ->setIntegrityCheck(false); // ADD This Line

        $query = $this->fetchAll($consulta)->toArray();
        return $query;
    }

}

Solved by adding ->setIntegrityCheck(false) ! =)

An explanation of why this helps is found at this question/answer

like image 56
Jhosman Avatar answered Oct 24 '22 06:10

Jhosman