$st = $this->pdo->prepare("insert into $tablename ($field) values($code)");
$st->execute($arr);
if ($this->pdo->errorCode() != '00000')test($this->pdo->errorInfo());
return $this->pdo->lastInsertId();
故意让一个不能为空的字段给一个空值,然后上面的代码执行后获取不到错误(也输出过errorCode() 是= '00000'),但pdo->lastInsertId()返回的是0,打开数据库去看也是没有成功新增记录,这种PDO预处理的SQL该怎么获取错误提示?
if ($st->errorCode() != '00000') test($st->errorInfo());
try { .... $st->execute($arr); ....} catch (PDOException $e) { print "Error!: " . $e->getMessage() . "\n";}