2008年11月10日星期一

Re: [fw-db] Zend Db Manual Query Problems

On Mon, Nov 10, 2008 at 10:21 AM, mikaelkael <perraud.mickael@orange.fr> wrote:
> Hi,
>
> I don't know exactly your problem with raw query. But with instance of
> Zend_Db_Table_Abstract, most of time, people forget to explicitly declare
> the from() part.
>
> Example:
> $table = new Members();
> $select = $table->select();
> $select->from($this);
> $select->join('groups', 'members.group_id=groups.id', 'groups.name');
> $rows = $table->fetchAll($select);||

You don't need to do ->from() in this case unless you need to query a
different table, etc.. and then it's (IMHO) cleaner to do $db =
$this->getAdapter(); $db->select()->etc()->pp().. If you stay on the
same table the from() is implied.

Till

没有评论: