尝试将值插入MySQL表后,出现此异常。我将不胜感激任何帮助。预先感谢。
致命错误:消息为'SQLSTATE [21S01]的未捕获异常'PDOException':>插入值列表与列列表不匹配:1136列计数与>第1行的值计数不匹配
表格:
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) COLLATE utf8_spanish_ci NOT NULL,
`password` varchar(64) CHARACTER SET utf8 NOT NULL,
`name` varchar(255) COLLATE utf8_spanish_ci DEFAULT NULL,
`number` varchar(10) COLLATE utf8_spanish_ci DEFAULT NULL,
`address` varchar(255) COLLATE utf8_spanish_ci DEFAULT NULL,
`role` char(1) COLLATE utf8_spanish_ci NOT NULL DEFAULT '2'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
PHP
public function insertar($usuario) {
$db = Conexion::conectar();
$insert = $db->prepare('INSERT INTO users (email,password,name,number,address,role) VALUES(NULL,:email,:address,:name,:number,:password,:role)');
$insert->bindValue('email', $usuario->getEmail());
$insert->bindValue('password', $usuario->getPassword());
$insert->bindValue('name', $usuario->getName());
$insert->bindValue('number', $usuario->getNumber());
$insert->bindValue('address', $usuario->getAddress());
$insert->bindValue('role', $usuario->getRole());
$insert->execute();
}