-1

我正在将我的 MySQL 查询切换到 PDO 准备语句。我的大多数查询都有效,但这个查询不起作用。它在“准备”方法之后立即中断。

你觉得哪里不对?

function get_users_days($item_ID, $user_ID)
{
    $today = date("Y-m-d");

    $SQL = "SELECT *
            FROM schedule 
            WHERE item_ID=:item_ID AND user_ID=:user_ID AND end_date>=:today";

    $stmt = $dbh->prepare($SQL);
    $stmt->bindParam(':item_ID', $item_ID);
    $stmt->bindParam(':user_ID', $user_ID);
    $stmt->bindParam(':today', $today);

    $stmt->execute();

    while($row = $stmt->fetch())
    {
      // do magical things
    }
}
4

1 回答 1

2

只需 在变量global $dbh; 之前添加$today

于 2012-08-18T22:38:50.120 回答