欢迎,
我有下表
Field Type Null Key Default Extra
topic_id int(10) unsigned NO PRI NULL auto_increment
topic_uri varchar(255) NO MUL
forum_id int(11) NO MUL 0
topic_title varchar(255) NO
when int(11) NO 0
topic_posts int(11) NO 0
first_post_user varchar(32) NO 0
first_post_when int(11) NO 0
last_post_user varchar(32) NO
last_post_when int(11) NO 0
topic_sticky int(11) NO 0
topic_locked tinyint(4) NO 0
topic_hidden tinyint(4) NO 0
我想使用PDO绑定make INSERT。
$b=$dbh->prepare("INSERT INTO `mybase`.`bx_forum_topic` (`topic_id`,`topic_uri`,`forum_id`,`topic_title`,`when,topic_posts`,`first_post_user`,`first_post_when`,`last_post_user`,`last_post_when`,`topic_sticky`,`topic_locked`,`topic_hidden`) VALUES (NULL,:topic_uri,:forum_id,:topic_title,:when,:topic_posts,:first_post_user,:first_post_when,:last_post_user,:last_post_when,:topic_sticky,:topic_locked,:topic_hidden)");
$test=12;
$b->bindParam(":topic_uri",$test);
$b->bindParam(":forum_id",$test);
$b->bindParam(":topic_title",$test);
$b->bindParam(":when",$test);
$b->bindParam(":topic_posts",$test);
$b->bindParam(":first_post_user",$test);
$b->bindParam(":first_post_when",$test);
$b->bindParam(":last_post_user",$test);
$b->bindParam(":last_post_when",$test);
$b->bindParam(":topic_sticky",$test);
$b->bindParam(":topic_locked",$test);
$b->bindParam(":topic_hidden",$test);
$b->execute();
print_r($dbh->errorInfo());
echo $dbh->errorCode();
它没有显示任何错误。错误表显示Array ( [0] => 00000 ) 00000
,但我的表中没有数据。
当我使用没有绑定时:
$b=$dbh->prepare("INSERT INTO `mybase`.`bx_forum_topic` (`topic_id`, `topic_uri`, `forum_id`, `topic_title`, `when`, `topic_posts`, `first_post_user`, `first_post_when`, `last_post_user`, `last_post_when`, `topic_sticky`, `topic_locked`, `topic_hidden`) VALUES (NULL, '12', '12', '12', '12', '12', '12', '12', '12', '12', '12', '12', '12')");
$b->execute();
print_r($dbh->errorInfo());
echo $dbh->errorCode();
它正在运作。
我在哪里弄错了?为什么它失败并且没有显示任何绑定错误?
答案 0 :(得分:1)
我想问题就在这里:
`when,topic_posts`