Php Mysql查询不通过JSON发送响应
所以我有一个疑问Php Mysql查询不通过JSON发送响应,php,mysql,json,Php,Mysql,Json,所以我有一个疑问 $sql="SELECT c.first_name, a.id, a.name, a.current_value,a.end_date from psf_customer c, psf_auctions a join psf_customer_bids b ON a.id=b.auction_id where c.user_id =b.user_id and TIMESTAMP (b.timestamp, '00:00:02') >= '$
$sql="SELECT c.first_name, a.id, a.name, a.current_value,a.end_date from psf_customer c,
psf_auctions a join psf_customer_bids b ON a.id=b.auction_id where c.user_id =b.user_id
and TIMESTAMP (b.timestamp, '00:00:02') >= '$now' order by b.timestamp DESC";
$now
这是一个具有以下日期(当前日期)的变量
这是通过
$bids = $this->Db->addSQL($sql)->execute()->fetchArray();
并发送响应
return json_encode($bids);
但当我试图得到回应时
var data = JSON.parse(d);
console.log(data);
此控制台不打印任何内容,查询在数据库上运行正常。我怀疑变量$now
需要以某种方式进行更改?尝试以下操作:
$sql="SELECT c.first_name, a.id, a.name, a.current_value,a.end_date from psf_customer c,
psf_auctions a join psf_customer_bids b ON a.id=b.auction_id where c.user_id =b.user_id
and TIMESTAMP (b.timestamp, '00:00:02') >= now() order by b.timestamp DESC";
试试这个:
$sql="SELECT c.first_name, a.id, a.name, a.current_value,a.end_date from psf_customer c,
psf_auctions a join psf_customer_bids b ON a.id=b.auction_id where c.user_id =b.user_id
and TIMESTAMP (b.timestamp, '00:00:02') >= now() order by b.timestamp DESC";
编辑:我将$now更改为当前_日期并收到响应。但是我不希望当前日期,而是希望$now工作,因为时间不同,您正在使用时间戳进行检查,所以使用
$now=time()代码>也许你可以使用mysql函数now()
。看起来你的代码不错。我认为日期$now不是您所期望的,服务器日期也没有设置,因为您认为这正是我所说的,当我用当前日期替换$now时,代码工作正常,但这不是我想要的。(因为我的当前日期不等于服务器时间)编辑:我将$now更改为当前_日期并收到响应。但是我不希望当前日期,而是希望$now工作,因为时间不同,您正在使用时间戳进行检查,所以使用$now=time()代码>也许你可以使用mysql函数now()
。看起来你的代码不错。我认为日期$now不是您所期望的,服务器日期也没有设置,因为您认为这正是我所说的,当我用当前日期替换$now时,代码工作正常,但这不是我想要的。(因为我的当前日期不等于服务器时间)我已将$now
替换为now()
我已将$now
替换为now()