http://framework.zend.com/manual/en/zend.db.table.relationships.html
http://framework.zend.com/manual/en/zend.db.table.relationships.html
Try something like this in your model:
public function consultaCadastro() {
$select = parent::select();
$select->setIntegrityCheck(false);
$select->from($this->_name, array('id_cidade','cidade')
->joinLeft('tab_estado','tab_estado.id_estado =
tab_cidade.id_estado',array('sigla'))
$results = parent::fetchAll($select)
return results;
}
helderfelipe wrote:
>
> I want to create a method that returns a array with the main table and the
> references, im doing this way:
>
> public function consultaCadastro(){
>
> # main
> $qry = $this->select()->from($this, array('id_cidade',
> 'cidade','tab_estado.sigla'));
>
>
> # Join
> $qry = $qry->setIntegrityCheck(false);
> $qry = $qry->joinLeft('tab_estado','tab_estado.id_estado =
> tab_cidade.id_estado', array());
>
> # return
> $rows = $qry->query()->fetchAll()
> return $rows;
> }
>
>
> But "$qry->setIntegrityCheck(false);" doesn't seem correct, and i don't
> like to write de join condition.
>
> Is there a more elegant way to do this ? Reference map solve this ? how
> can i do ?
>
-----
visit my website at http://www.phpscriptor.com/ http://www.phpscriptor.com/
--
View this message in context:
http://www.nabble.com/Zend_db_tab-relationship-tp23137713p23170643.html
Sent from the Zend Framework mailing list archive at Nabble.com.