Hola a todos quesiera saber si es que se puede replicar esta consulta sql usando zend framework
Cita: SELECT DISTINCT "r"."id_rol", "r"."nombre", "rp"."persona"
FROM "rol" AS "r" LEFT JOIN "persona_rol" AS "rp"
ON r.id_rol=rp.rol AND (rp.persona='per-121')
WHERE (r.estado='Activo')
ORDER BY "rp"."persona" ASC
yo la tengo planteada de esta manera
Código PHP:
public function findAllNotAsigned1($persona) {
$results = array();
$db = $this->getAdapter ();
$select = $db->select ();
$select->distinct(TRUE);
$select->from ( array ('r' => 'rol' ), array ('id_rol', 'nombre' ) );
$select->joinLeft( array ('rp' => 'persona_rol' ), 'r.id_rol=rp.rol AND rp.persona="'.$persona.'"',array('persona') );
// $select->where ( 'rp.persona=?', $persona );
$select->where ( 'r.estado=?', 'Activo' );
$select->order ( 'rp.persona' );
echo $select->__toString();
$results = $db->fetchAll ( $select );
return $results;
}
pero me sale este error
Código HTML:
exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[42703]: Undefined column: 7 ERROR:
column "per-105" does not exist LINE 2: ...na_rol" AS "rp" ON r.id_rol=rp.rol AND rp.persona="per-105" ... ^' in D:\MobiusWS\Quantum\library\Zend\Db\Statement\Pdo.php:238 Stack trace: #0 D:\MobiusWS\Quantum\library\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array) #1 D:\MobiusWS\Quantum\library\Zend\Db\Adapter\Abstract.php(433): Zend_Db_Statement->execute(Array) #2 D:\MobiusWS\Quantum\library\Zend\Db\Adapter\Pdo\Abstract.php(230): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Select), Array) #3 D:\MobiusWS\Quantum\library\Zend\Db\Adapter\Abstract.php(644): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Select), Array) #4 D:\MobiusWS\Quantum\application\default\models\RolModel.php(62): Zend_Db_Adapter_Abstract->fetchAll(Object(Zend_Db_Select)) #5 D:\MobiusWS\Quantum\application\default\controllers\UsermanagerController.php(92): RolModel->findAllNotAsigned1('per-105') #6 D:\MobiusWS\Quantum\library\Zend\Controller\Action.php(503): UserManagerController->editarAction() #7 D:\MobiusWS\Quantum\library\Zend\Controller\Dispatcher\Standard.php(285): Zend_Controller_Action->dispatch('editarAction') #8 D:\MobiusWS\Quantum\library\Zend\Controller\Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(
plis si alguien puede ayudar le estare agradecido