Select query cannot join with another table - JOIN Zend Framework
Asked Answered
B

1

7

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

Banister answered 5/7, 2014 at 21:38 Comment(1)
$select->setIntegrityCheck(false); add this line (from the below answer)Septa
B
25
<?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

Banister answered 6/7, 2014 at 2:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.