我遇到了一个小问题。我有以下代码:
$query = $db->prepare('(SELECT last_visit, last_ip FROM user_log WHERE user_id = :id)
UNION
(SELECT time AS last_visit, packet_hex AS last_ip FROM crack_log WHERE target_id = :id)
ORDER BY last_visit DESC LIMIT 0,10;');
$query->execute(array(':id'=> $_SESSION['id']));
$log = $query->fetchAll(PDO::FETCH_ASSOC); //Last visit/IP
var_dump($log);
返回:
array(0) { }
我已经在 phpmyadmin 中尝试过查询,它运行良好。你能帮我找出错误吗?