0
我将id设置为标识主键,但此代码返回null,我不想使用@@IDENTITY
。为什么SCOPE_IDENTITY()返回空值?
$stmt = $db->prepare("INSERT INTO `question_field`(`q_field_id`, `q_field`) VALUES ('','software');SELECT SCOPE_IDENTITY() as last_id");
$stmt->execute();
$row=$stmt->fetch();
echo $row['last_id'];
什么问题?如果该功能是任何插入语句插入标识列发生的范围援引
即原始查询将返回一个错误,因为您正试图将''插入到'身份'列中。 – StuartLC