我需要帮助,我在codeIgniter上有这样的查询
select *
from meter_list
where metertimestamp BETWEEN
to_date('2010/03/15 05:06', 'YYYY/MM/DD HH24:MI')
and
to_date('2015/03/15 05:06', 'YYYY/MM/DD HH24:MI');
我在我的代码中尝试这样:
$this->_db_oracle->where('METERTIMESTAMP >=', $tgl1);
$this->_db_oracle->where('METERTIMESTAMP <=', $tgl2);
$query = $this->_db_oracle->get('MTR_METERLIST');
但我收到以下错误:
错误号码:
SELECT * FROM&#34; MTR_METERLIST&#34;在哪里&#34; METERTIMESTAMP&#34; &GT; 0和&#34; METERTIMESTAMP&#34; &LT; 0
行号:330
请帮助解决我的代码。抱歉我的英文不好,谢谢
答案 0 :(得分:-1)
只需尝试使用代码并在oracle上使用“查询”来获取fire SQL。 像:
public function __construct(){
$this->CI =& get_instance();
$this->_KISS_DB = $this->CI->load->database('kiss', TRUE);
}
function current_semester(){
$strSQL = "select * from meter_list where metertimestamp BETWEEN
to_date('2010/03/15 05:06', 'YYYY/MM/DD HH24:MI')
and
to_date('2015/03/15 05:06', 'YYYY/MM/DD HH24:MI') ";
$query = $this->_KISS_DB->query($strSQL);
foreach ($query->result() as $row)
{
echo $row->COURSE_CODE;
}
}