dongshandun4363 2014-04-04 09: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 23:26
    关注

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

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

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集