开发者

try to perform a query with join with Zend (SE)

I have 4 tables on my DB; merchants, pay_method, spendings ans transaction_type.

They all have an id and a title, except spend (spend have the Foreign keys of the others and other field like user_id, comment, ... ).

I try to have all the informations of all the tables for an unique user_id!

for perform it, I tried a little test that doesn't run :

public function getSpendingsForUser( $userid )
{
    $mercTable = Engine_Api::_()->getDbTable('merchants', 'spendings');
    $mercName = $mercTable->info('name');   

    $table = Engine_Api::_()->getDbTable('spendings', 'spendings');
    $spendName = $table->info('name');

    $select = $table->fetchAll(
        $table->select()
        ->joinLeft($mercName, "$mercName.merchant_id = $spendName.merchant_id", NULL)
        ->where('user_id = ?', $user开发者_开发技巧id)
        ->group('spending_id')
        );
    return $select;

}

An in the view file :

foreach($this->spendings as $s) {
        var_dump($s->comment);
}

How can I make the join correctly to have all the info from the user_id ???

Thanks a lot !!!


You should define doesn't run to help us help you. But I can tell you you probably need to ->setIntegrityCheck(false);

$select = $table->fetchAll(
        $table->select()
        ->setIntegrityCheck(false);
        ->joinLeft($mercName, "$mercName.merchant_id = $spendName.merchant_id", NULL)
        ->where('user_id = ?', $userid)
        ->group('spending_id')
        );

Before the join.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜