我在Drupal模块中有一个表单我试图提交以创建一个"事件"。事件表结构是:
当我尝试创建一个新事件并使用以下命令将其插入数据库时
$eid = db_insert('events')->fields(array(
'cid' => $cid,
'name' => $name,
'time' => $time,
'date' => $timestamp,
'data' => $extra_info,
'event_type' => $checked, //this is an array of checked checkboxes
))->execute();
它引发了一个错误说:
PDOException :SQLSTATE[HY093]: Invalid parameter number: parameter was not defined: INSERT INTO {events} (cid, name, time, date, data, event_type) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5_Games, :db_insert_placeholder_5_Other); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => Name [:db_insert_placeholder_2] => 23.30 [:db_insert_placeholder_3] => 1313020800 [:db_insert_placeholder_4] => More [:db_insert_placeholder_5_Games] => Games [:db_insert_placeholder_5_Other] => Other ) in event_creation_submit().
关于我做错什么的任何想法?
由于
答案 0 :(得分:1)
管理以解决问题。
将event_type
字段的类型更改为集合,并将其传递给一串值而不是数组。这解决了它。
感谢大家的帮助!