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)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?