このエラーの解決策はありますか?クエリのmySQL時間形式が原因で発生していますか?
SQLエラー エラー:SQLSTATE [HY093]:無効なパラメーター番号:バインドされた変数の数 トークンの数と一致しません 配列 (( [:service_user_id] => 90 [:week_beginning] => 2012-08-06 [:week_ending] => 2012-08-12 )。 バックトレース:C:\ wamp \ www \ Sitetest_9.6.12 \ public_html \ main \ ajax \ timetable_grid_load.php、45行目
これは、 php-pdo-wrapper-classを使用するPHPです。
$bind = array(
":service_user_id" => $service_user_id,
":week_beginning" => $week_beginning,
":week_ending" => $week_ending,
);
$query = "SELECT
id AS sessID,
session_day as sessDay,
session_type_id,
provider_id,
description,
TIME_FORMAT(start_time, '%H:%i') as start_time,
TIME_FORMAT(finish_time, '%H:%i') as finish_time,
start_date,
finish_date,
(SELECT absence FROM attendance WHERE sessID = session_id AND absence_date = DATE_ADD(':week_beginning', INTERVAL sessDay-1 DAY)) AS attendance
FROM
sessions
WHERE
service_user_id = :service_user_id AND
start_date <= ':week_ending' AND
(finish_date >= ':week_beginning' OR
finish_date IS NULL OR
finish_date=0)
ORDER BY session_day ASC";
$result= $db->run($query,$bind);
return $result;