使用NotORM选择比今天更大的日期

时间:2014-03-01 04:49:52

标签: php pdo notorm

我使用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有何意义?

2 个答案:

答案 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");