ai didi

php - 如何在 codeIgniter 中正确地进行查询?

转载 作者:行者123 更新时间:2023-11-29 15:26:11 24 4
gpt4 key购买 nike

如何在 PHP 中正确地进行查询?

$where = "MONTH('leave_date') = ".$data['currM']."' AND YEAR('leave_date') = '".$data['currY']."' AND agent_id = '".$list->ps_crm_agent_id;

数据库错误;

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' AND YEAR('leave_date') = '2019' AND agent_id = '7' at line 3

SELECT `ps_crm_agent_leaves`.* FROM `ps_crm_agent_leaves` WHERE 
MONTH('leave_date') = 11' AND YEAR('leave_date') = '2019' AND `agent_id` = '7

最佳答案

你忘记了一些单引号

$where = "MONTH('leave_date') = '".$data['currM']."' AND YEAR('leave_date') = '".$data['currY']."' AND agent_id = '".$list->ps_crm_agent_id."'";
^ ^
here here

关于php - 如何在 codeIgniter 中正确地进行查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59075705/

24 4 0
文章推荐: javascript - Highcharts:在图例上显示系列但在图表上隐藏
文章推荐: mysql - 查询,联接和求和问题,返回错误
文章推荐: javascript - 如何从 getByteFrequencyData 正确确定以 dB 为单位的音量
文章推荐: PHP从输入插入到mysql变量值
行者123
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com