0
我在我的DB上有4個表格; 商家,pay_method,花費ans transaction_type。嘗試使用Zend(SE)連接執行查詢
它們都有一個id和一個標題,除了花費(花費了其他字段的外鍵以及其他字段,如user_id,comment,...)。
我嘗試擁有一個唯一user_id的所有表的所有信息!
的執行它,我嘗試了一些測試,不運行:
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 = ?', $userid)
->group('spending_id')
);
return $select;
}
一個視圖中的文件:
foreach($this->spendings as $s) {
var_dump($s->comment);
}
我怎樣才能使連接正確掌握所有來自user_id的信息?
非常感謝!
好的我會試試這個;-) – clement
@clement它工作嗎? – Iznogood
它更好用;-)謝謝 – clement