[英]Zend Framework DB Select doesn't get the data for the whole row
我很沮喪
我有一組數據庫,這些數據庫保存客戶數據,諸如client_personal中的個人詳細信息以及client_contact中的聯系詳細信息之類的東西。這里有6個聯接正在收集一整行信息。 因此,從邏輯上(或我認為),我做到了;
$oSelect->from(array('details' => 'client_details'))
->joinLeft(array('contact' => 'client_contact'), 'contact.client_id = details.id')
->joinLeft(array('other' => 'client_other_details'), 'other.client_id = details.id')
->joinLeft(array('nok' => 'client_nextofkin'), 'nok.client_id = details.id')
->joinLeft(array('notes' => 'client_notes'), 'notes.client_id = details.id')
->joinLeft(array('contract' => 'client_contract'), 'contract.client_id = details.id')
->joinLeft(array('image' => 'client_image'), 'image.client_id = details.id')
->where('details.id = ?', $cid);
現在,這返回了大量信息,但是我的測試數據中缺少某些字段。 例如,client_contact包含:
id client_id email phone mobile phone address postcode country
雖然我已經驗證了所有字段都包含一些測試數據,但我正在獲取除“ phone”和“ address”以外的每個字段的數據-phone是一個varchar(11)字段,與mobile相同,取出數據,地址是一個文本字段,與郵政編碼(對於本測試而言)相同,我也要獲取數據。
它並不會丟失-運行后立即顯示var_dump() ->fetch()
表明它只是沒有從數據庫中獲取數據。 我轉儲了該代碼產生的語句,然后自己運行了該語句,並在所有行中獲取了數據。
這里發生了什么?
沒關系。 這里發生的事情與兩個表的內容有關:client_details和client_nextofkin。
這兩個表都包含標記為“地址”和“電話”的字段,並且由於聯系方式表之后的親屬表的下一個進入聯接,因此這些字段在我的結果集中被覆蓋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.