将MySQL转换为PDO不会返回任何结果

时间:2017-06-01 09:50:13

标签: pdo

我的任务是将所有MySQL查询转换为PDO。这很好,直到这一个查询在PDO表单中无法正常工作。

查询的MySQL版本,运行正常,是:

$queryPages = "SELECT m.member_id, p.page_id, p.live, p.version, p.page_title, p.page_locked_for_editing, p.form, p.folder_main_page, p.expire_date, DATE_FORMAT(p.published_date, '$DATESQL') AS published_date, p.author_id, m.firstname, m.surname FROM pages AS p LEFT JOIN members AS m ON m.member_id = p.author_id WHERE p.folder_id = '$folder_id' ORDER by p.folder_main_page DESC, p.page_id DESC";

$resultPages=mysqli_query(db_connect(), $queryPages);

我创建的PDO版本是:

$sql = "SELECT m.member_id, p.page_id, p.live, p.version, p.page_title, p.page_locked_for_editing, p.form, p.folder_main_page, p.expire_date, DATE_FORMAT(p.published_date, ?) AS published_date, p.author_id, m.firstname, m.surname FROM pages AS p LEFT JOIN members AS m ON m.member_id = p.author_id WHERE p.folder_id = ? ORDER by p.folder_main_page DESC, p.page_id DESC";

$stmt = $dbh->prepare($sql);
$resultPages = $stmt->execute([$DATESQL, $folder_id]);

我猜这与DATE_FORMAT部分有关,但不确定如何更改它。

0 个答案:

没有答案