2013-01-05 33 views
0

有一個解決我的sql查詢的stackoverflow問題,但是我似乎無法做到這一點CodeIgnighter。ActiveRecord - 只有在沒有其他表時纔會得到結果

到目前爲止,我想出了在SO

$this->db->select('shop_coupons_assoc.*'); 
$this->db->select('shop_products.*'); 
$this->db->where('shop_products.id IS NULL'); 
$this->db->join('shop_coupons_assoc', 'shop_coupons_assoc.product_id = shop_products.id', 'left'); 

文章,這似乎是在SQL我嘗試做

更新 我的問題:我怎麼會寫在Codeignighter的SQL(主動記錄格式)

- 上述代碼似乎沒有執行

考試我需要什麼。只是不能找到codeignighter文檔

SQL - find records from one table which don't exist in another

How to select all records from one table that do not exist in another table?

+0

那又有什麼問題呢? ;) – bonCodigo

回答

0

將這個腳本的下方,用var_dump來測試它:

$result = $this->db->get()->result(); 
var_dump(result); 

編輯: 我現在看到的錯誤:

$this->db->where('shop_products.id IS NULL'); 

應該

$this->db->where('shop_products.id IS', NULL); 

你可能忽略了逗號和榮譽的文檔中的字段名之後。此外,空白頁面可能是因爲您的服務器php.ini已將error_reporting轉爲或因爲您正在生產環境中工作。

+0

我只是得到一個黑屏,我做了一個跟蹤和它的失敗在這條線''空'' – IEnumerable

相關問題