我在使用 PDO 时遇到了一些问题。一切似乎都是正确的,但我收到了这个错误
SQLSTATE[HY000]: General error: 1366 Incorrect integer value: ':permissao' for column 'permissao' at row 1\n
这是打印输出的代码
$this->nome = $nome;
$this->email = $email;
$salt = $this->generateSalt();
$permissao = 10;
$activo = 0;
#encripta chama a funcao para encriptar a password do utilizador
$this->password = $this->pwdEncript($password, $salt);
$params = array('nome'=>$this->nome,
'email'=> $this->email,
'password'=> $this->password,
'salt'=>$salt,
'permissao'=>$permissao,
'activo'=>$activo);
$sql = "INSERT INTO sys_users(nome,email,password,salt,permissao,activo)
VALUES(':nome',':email',':password',':salt',':permissao',':activo')";
try
{
$sth = $this->db->prepare($sql);
$sth->execute($params);
}
catch(PDOException $e)
{
echo 'Erro ao inserir na base de dados'.$e->getMessage().'\n';
}
Permissao 是 mysql 表上的一个 INT。
很高兴在这方面提供任何帮助;)