我使用NotORM:
进行了简单的查询(或者我认为)$query = $db-> irregular
->select('id','name','starttime','endtime')
->where('customer_id',$_SESSION['user']['customer_id'])
->where("startdate > ? ", new NotORM_Literal("NOW()")) );
“?”在上面的例子中没有被替换。查询只是读取
SELECT id, name, starttime, endtime FROM irregular WHERE (customer_id = '1') AND (startdate > ? )
这对NotORM有何意义?
答案 0 :(得分:2)
将now()的值赋给变量并在where子句
中使用它$now =new NotORM_Literal("NOW()");
$query = $db-> irregular()
->select('id','name','starttime','endtime')
->where('customer_id',$_SESSION['user']['customer_id'])
->where("startdate > $now")->fetch();
或
$query = $db-> irregular(array('customer_id'=>$_SESSION['user']['customer_id']))
->select('id','name','starttime','endtime')
->where("startdate > $now")->fetch();
答案 1 :(得分:0)
使用类似这样的内容:
$jobs = $this->db->jobs->where(array("deleted" => 1, "id" => $id))
->select('id', 'startDate')
->where('startDate < ?',$maxStartDate)
->where('startDate > ?',$minStartDate)
->order("id desc");