colshrapnel / thebestpdowrapper

World's simplest PDO wrapper
35 stars 8 forks source link

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error #18

Closed tablecell closed 4 years ago

tablecell commented 4 years ago

as readme.md documented


$name='test';
$pass='test';
$email='test@my.com';

$sql  = "INSERT INTO users VALUES (NULL,?,?,?)";
$user = DB::prepare($sql)->execute([$name,$pass,$email])->fetch();
$id   = DB::lastInsertId();
echo $id;

table schema is

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `pass` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
colshrapnel commented 4 years ago

what are you trying to fetch from the INSERT query?