這是學說碼在ZF應用:主義innerjoin
$rowset = Doctrine_Query::create()
->select("cu.clientuser, cu.usertitle, u.firstname")
->from('Model_Db_Tblclientuser cu')
->innerJoin('cu.Tblusers u')
->whereIn('cu.clientid', (int)$clientid)
->execute();
foreach ($rowset as $row) {
$list[] = array(
'title' => $row->usertitle,
'firstname' => $row->firstname
);
}
一個已經生成的查詢是這樣的一個:
SELECT
t.clientuser AS t__clientuser,
t.usertitle AS t__usertitle,
t2.userid AS t2__userid,
t2.firstname AS t2__firstname
FROM
tblclientuser t INNER JOIN tblusers t2 ON t.userid = t2.userid
WHERE
(t.clientid IN (1))
複製粘貼到phpMyAdmin的,它給出了一個完美結果。 但是當我運行ZF應用程序時,它出錯...
對於「clientuser」字段,一切正常。 但對於外地「名字」這是走錯了......
Unknown record property/related component "firstname"
on "Model_Db_Tblclientuser"
我該怎麼辦錯了嗎?
很奇怪的一點需要注意:如果我做
foreach ($rowset as $row) {
var_dump($row);
}
它與其他總表輸出的東西爲好,表並不在所有問題......
nope ..沒有幫助我。無論如何,Thx! – Aerypton 2012-04-03 18:45:33