Mysql查询不通过JSON

时间:2015-10-12 07:00:24

标签: 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') >= '$now' order by b.timestamp DESC";

$now这是一个具有以下日期的变量,(当前日期)

$now = date('Y-m-d H:i:s');

正在通过

执行
 $bids = $this->Db->addSQL($sql)->execute()->fetchArray();

并发送回复

return json_encode($bids);

但是当我试图得到回应时,

 var data = JSON.parse(d);
              console.log(data); 

这个控制台什么都不打印,查询在数据库上运行正常。我怀疑变量$now需要以某种方式改变吗?

1 个答案:

答案 0 :(得分:0)

试试这个:

$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";