dongshandun4363 2014-04-04 01:45
浏览 11
已采纳

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

I've a problem while getting schedules from my datebase

DB:

Schedules

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

The left join

 //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();

 }

//Note: The left join works fine I just stripped some stuff out

The problem is I want to check if start is the same as i.start_time but one is a date and one is a datetime.

Is there a way to convert i.start_time to a date format in the left join?

//Note: This is zend 1! And also it is built in a cms

  • 写回答

1条回答 默认 最新

  • douzhenzu0247 2014-04-04 15:26
    关注

    Converting your WHERE clause to the following should do the trick:

    ->where('DATE(i.start_time) = DATE(?)', $start)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部