PHP zend在查询中保留了连接转换日期

时间:2014-04-04 09:45:12

标签: php mysql sql zend-framework join

从我的日期基础获取时间表时出现问题

DB:

时刻表

ID: 1
start_time : 2014-04-04 08:00:00
and more..

左连接

 //start is defined as : $start = '2014-04-04'

 public function getEntriesForWebuserByDate($businessId,$userId,$date){

    $select = $this->select()->setIntegrityCheck(false)
          ->from(array('i' => $this->_name), array('*'))
          ->where('i.start_time = "'.$start.'"') //Both should be dates

          $select->where('(b.instance_id = ?)', $businessId);
          return $select->query()->fetchAll();

 }

//注意:左连接工作正常我只是删除了一些东西

问题是,我想检查start是否与i.start_time相同,但一个是日期,一个是日期时间。

有没有办法将i.start_time转换为左连接中的日期格式?

//注意: 这是zend 1!它也是用cms构建的

1 个答案:

答案 0 :(得分:1)

将WHERE子句转换为以下内容应该可以解决问题:

->where('DATE(i.start_time) = DATE(?)', $start)