join problems. output isn't in the variable
function viewAction() {
$this->view->title='Příspěvek';
$this->post=new Post();
$select=$this->post->select();
$select->setIntegrityCheck(false);
$select->from($this->post,array('id','name','activity','id_no','post', 'attachment','date_format(created,"%d.%m.%Y") AS datum'));
$select
->join(array('u'=>'users'),'u.id=posts.user_id')
->join(array('cat'=>'category'),'posts.category_id= cat.id','category')
->join(array('loc'=>'locality'),'loc.id=posts.local ity_id')
->order("created DESC")->limit(1);
echo $select;
//po->limit(5,5);
//Zend_Debug::dump($select);
$this->view->post=$this->post->fetchAll();
}
creates me a query like this:
SELECT `posts`.`id`, `posts`.`name`, `posts`.`activity`, `posts`.`id_no`, `posts`.`post`, `posts`.`attachment`, date_format(created,"%d.%m.%Y") AS `datum`, `u`.*, `cat`.`category`, `loc`.* FROM `posts` INNER JOIN `users` AS `u` ON u.id=posts.user_id INNER JOIN `category` AS `cat` ON posts.category_id=cat.id INNER JOIN `locality` AS `loc` ON loc.id=posts.locality_id ORDER BY `created` DESC LIMIT 1
however, when i vardump $this->view->post i don't get data from joined tables.
|