gpt4 book ai didi

php - 如何在 Zend Framework 查询之间放置

转载 作者:搜寻专家 更新时间:2023-10-31 21:15:45 24 4
gpt4 key购买 nike

任何人都可以根据 ZF 更正此查询。我遇到用户选择不同参数并在此基础上进行查询的情况

$user = new Zend_Session_Namespace('user');
$phone_service_id = $user->phone_service_id;

$start_date = $this->_getParam('start_date'); //02/07/2012
$end_date = $this->_getParam('end_date'); //02/21/2012
$option_call_log = $this->_getParam('option_call_log'); //COLUMN NAME
$option_call_log_asc_desc = $this->_getParam('option_call_log_asc_desc'); //ASC/DESC

我想我在查询中有语法错误,请看这里

$select = $DB->select()
->from('CALL_LOG', array('caller_name','call_number','call_start_time','call_duration','call_direction'))
->where('phone_service_id = ?', $phone_service_id)
->where(DATE_FORMAT(date_created, '%m/%d/%Y') BETWEEN $start_date AND $end_date)
->order($option_call_log $option_call_log_asc_desc)
->limit(0,9);

这是怎么回事??

最佳答案

BETWEEN子句是包含的,正确的做法如下:

$select = $DB->select()
->from('CALL_LOG', array('caller_name','call_number','call_start_time','call_duration','call_direction'))
->where('phone_service_id = ?', $phone_service_id)
->where("DATE_FORMAT(date_created, '%m/%d/%Y') >= ?", $start_date)
->where("DATE_FORMAT(date_created, '%m/%d/%Y') <= ?", $end_date)
->order("".$option_call_log." ".$option_call_log_asc_desc)
->limit(0,9);

试试上面的代码,你的问题就解决了。

关于php - 如何在 Zend Framework 查询之间放置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9206727/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com