【发布时间】:2012-06-16 17:34:11
【问题描述】:
使用以下代码:
db_update('nodesequence_nodes')
->fields(array(
'order' => 1,
))
->condition('nid', 1, '=')
->condition('nsid', 1, '=')
->execute();
我收到以下错误:
PDOException: SQLSTATE[42000]: 语法错误或访问冲突:1064 您的 SQL 语法有错误;检查手册 对应于您的 MySQL 服务器版本,以便使用正确的语法 在第 1 行靠近 'order='1' WHERE (nid = '1') AND (nsid = '1')':更新 {nodesequence_nodes} SET order=:db_update_placeholder_0 WHERE (nid = :db_condition_placeholder_0) 与 (nsid = :db_condition_placeholder_1) ;数组 ( [:db_update_placeholder_0] => 1 [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => 1 ) 在 nodesequence_init() 中(第 13 行) /var/www/eventbooking2/sites/all/modules/nodesequence/nodesequence.module)。
很抱歉,我无法提供更多见解,但我希望你能提供。
简单的db_update 代码在我看来应该可以工作,但我不知道为什么不能。
数据库架构:
$schema['nodesequence_nodes'] = array(
'description' => 'Relating nodesequences to their consituent nodes.',
'fields' => array(
'nsid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
'order' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
),
'primary key' => array('nsid', 'nid'),
);
【问题讨论】:
-
对我来说看起来不错。这是自定义表吗?如果是这样,你能显示你的表模式吗?
-
我刚刚包含了数据库模式。谢谢