私は困惑しています。
クライアントデータ、たとえば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
すべてのフィールドにいくつかのテスト データが含まれていることを確認しましたが、「電話」と「住所」を除くすべてのフィールドのデータを取得しています。電話は varchar(11) フィールドで、モバイルと同じです。データを取得し、住所はテキストフィールドで、データを取得している郵便番号 (このテストの目的で) と同じです。
途中で迷子になることはありません。実行直後の var_dump()->fetch()
は、データベースからデータを取得していないことを示しています。このコードが生成するステートメントをダンプして自分で実行し、すべての行でデータを取得しました。
何が起きてる?