简体   繁体   中英

Mysql query doesnt send response via JSON

So i have this query,

$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 here is a variable which has the following date, (Current date)

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

which is being executed via

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

and sending the response

return json_encode($bids);

but when i try to get the response,

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

this console prints nothing, the query is working fine on the database. i suspect the variable $now needs to be altered somehow?

Try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM