我正在使用php PDO ,当我使用下面的查询时出现此错误,
SQLSTATE[HY000]: General error
查询,
CREATE TEMPORARY TABLE temp_tb
SELECT * FROM person;
ALTER TABLE temp_tb
DROP type;
SELECT *
FROM temp_tb AS p
LEFT JOIN user AS u
ON p.person_id = u.person_id
LEFT JOIN category AS c
ON u.category_id = c.category_id
WHERE u.signature = ?
他们的查询是创建临时表,然后从该临时表中删除一列,然后将其与其他表连接。
当我直接在 phpMyAdmin 上查询而不是通过PDO查询时,它返回结果OK。我在查询或PDO中做错了什么?我怎么能解决这个问题?
修改
PDO,
public function fetch_object($query, $params = array())
{
try
{
# prepare the query
$stmt = $this->connection->prepare($query);
# if $params is not an array, let's make it array with one value of former $params
if (!is_array($params)) $params = array($params);
# execute the query
$stmt->execute($params);
# return the result
return $stmt->fetchObject();
//return $stmt->fetch(PDO::FETCH_OBJ);
}
catch (PDOException $e)
{
# call the get_error function
$this->get_error($e);
}
}
$user = $this->database->fetch_object($sql,$authenticated_user);
误差,
SQLSTATE [HY000]:常规错误