好的,所以我无法弄清楚如何使用php从mysql中检索数据,其中我有一个变量作为整数。 在数据库时间是(int)11
在phpmyadmin我的查询是,我得到了正确的结果
SELECT * FROM `transactions` WHERE (`sender` = "f3a8ce96-bfb9-410a-81fb-9deffb7305b2" OR `receiver` = "f3a8ce96-bfb9-410a-81fb-9deffb7305b2") AND `time` >= 1437249470
在php中我有
$past = "1437249470";
$user = "f3a8ce96-bfb9-410a-81fb-9deffb7305b2";
$sql = "SELECT * FROM transactions WHERE (sender = '".$user."' OR receiver = '".$user."') AND FROM_UNIXTIME(time) >= $past LIMIT 10";
在PHP中,它给了我随机而不相关的结果
如何让它在php中正常工作,就像在phpmyyadmin中一样?
示例输出 phpymadmin:
Quill Littlefeather Josh Piper $275 07/24/15 Object Buy 7/24/2015 7:57:50 AM
PHP:
Quill Littlefeather Josh Piper $275 04/16/15 Object Buy 4/16/2015 3:41:12 AM
在php中,结果应该与在phpmyadmin中的结果相同。
是的,我知道这不是pdo风格,但是pdo是一种痛苦而且过于复杂。
答案 0 :(得分:0)
这个问题的答案是我有
$sql = "SELECT * FROM transactions WHERE (sender = '".$user."' OR receiver = '".$user."') AND FROM_UNIXTIME(time) >= $past LIMIT 10";
应该是
$sql = "SELECT * FROM transactions WHERE (sender = '".$user."' OR receiver = '".$user."') AND time >= '".$past."' LIMIT 10";