我一直在使用一個庫子查詢的工作 - Subquery.php 編號:https://github.com/NTICompass/CodeIgniter-SubqueriesPHP笨 - 錯誤而執行庫Subquery.php
$this->db->select('test');
$this->db->select('test2');
$this->db->from('table');
$sub = $this->subquery->start_subquery('where_in');
$sub->select('IDs');
$sub->from('idTable');
$sub->where('date', '2011-07-10');
$this->subquery->end_subquery('id');
我認爲這樣的說法:
$sub = $this->subquery->start_subquery('where_in');
包含錯誤。當我執行這一行時,我得到一個空白頁。 fn。 start_subquery是:
function start_subquery($statement, $join_type = '', $join_on = 1){
$db = $this->CI->load->database('', true); // after executing this statement, a blank page shows...
$this->dbStack[] = $db;
$this->statement[] = $statement;
if(strtolower($statement) == 'join'){
$this->join_type[] = $join_type;
$this->join_on[] = $join_on;
}
return $db;
}
FYI - 我在database.php中:
$active_group = 'default'
$active_record = TRUE;
和CI版本2.1.0
試試你的控制器:'$ this-> load-> database('',true);'檢查它! – uzsolt
感謝您的回覆,但是...不,它不工作。 :(如果是這種情況,應該用下面的語句替換:$ db = $ this-> CI-> load-> database('',true);在start_subquery函數中? –
load-> database( )'應該可以工作,所以請不要改變!我認爲這個子查詢庫是可以的。恕我直言,你的數據庫配置在CI中是這樣的:http://codeigniter.com/user_guide/database/configuration.html 請檢查! – uzsolt