Добро пожаловать,
У меня есть следующая таблица
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
Я хочу сделать INSERT, используя привязку PDO.
$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();
Это работает.
Где я сделалошибка?Почему происходит сбой и не отображается ошибка с привязкой?