2008年8月16日星期六

Re: [fw-db] Problem with Zend_Db_Select

On Fri, Aug 15, 2008 at 10:37:12PM -0700, Pasha Mahardika wrote:
>
> I have EnginePosts(Zend_Db_Table) and i try to create a Zend_Db_Select with
> join option like this :
> $this->table = new EnginePosts();
> $select = $this->table->select()->setIntegrityCheck(false);
> $select->joinLeft("engine_term_relation","term_rel_id_obj =
> engine_post.post_id");
>
> and i've got this error :
> Uncaught exception 'Zend_Db_Table_Row_Exception' with message 'Specified
> column "post_date" is not in the row' in
> C:\AppServ\www\zendku\library\Zend\Db\Table\Row\Abstract.php:182.......

You try to go the wrong way ;-)

Show this example:
$db = Zend_Registry::get('db');
$select = $db->select()
->from('engine.post', array('post_id'))
->joinLeft('engine_term_relation', 'term_rel_id_obj =
engine_post.post_id');
$db->setFetchMode(Zend_Db::FetchOBJ) // as example
// do other stuff

What you doing in your example is mixing the Zend_Db_Table way with
the Zend_Db_Select way. That doesnt work. I like the Zend_Db_Select
way, it is more flexible.

Show the fine documentation for Zend_Db_Select. It has many
examples.

Happy coding
Mario Guenterberg

--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/CM d- s++: a+ C++++>$ UBL*++++$ P++ L+++ E--- W+++ N+ o-- K- w O- M-
V-- PS++ PE++ Y PGP+++ t--- 5 X++++ R++ tv- b+++ DI D++++ G++ e* h----
r+++ y++++
------END GEEK CODE BLOCK------

没有评论: