首先:我在google和stackoverflow中搜索:在mysql中插入自动增量id,found this on SO but it was not helpful。我发现的其他东西都是为mysqli-> insert_id; 如果我错过了寻找解决方案的一点,我会在评论中提供正确的链接。插入autoincrement id mysql到mysqli
我试图“翻译”旧的mysql_ -functions到mysqli_函数。
假设我的旧的查询是:
对于理解: ($clean[currURL]
= mysql_real_escape_string($_POST['currURL']);
)
新它必须是这样的:
$query = "INSERT INTO `bugtracker` (`id`, `date`, `workerid`, `currURL`, `prevURL`, `bugTitle`, `bugDesc`) VALUES (?, ?, ?, ?, ?, ?, ?)";
$statement = $mysqlicon->prepare($query);
$statement->bind_param('iiissss', 'NULL??', time(), $worker, $_POST['currURL'], $_POST['prevURL'], $_POST['bugTitle'], $_POST['bugDesc']);
$statement->execute();
$statement->close();
问:我没有不管怎么样,我都试图运行我的查询,因为我很好奇我应该如何在mysqli中将前一个“NULL”插入到我的autoincrement id中。我应该忽略并且将它留空吗?只是不要在$query
和bind_param
中显示?
表结构是按以下顺序: id
(INT11),date
(INT11),workerid
(INT11),currURL
(VARCHAR),prevURL
(VARCHAR),bugTitle
(VARCHAR),bugDesc
(文本)
因此,一个告诉你忽略该列的答案是“没有帮助”,而一个答案告诉你省略该列的工作就像一个魅力。 PHP用户的典型逻辑。 – 2017-08-08 08:35:24