我正在向数据库发布一个新行,但想使用 medoo 在响应中返回新的自动递增 id。这似乎正在生成一个新的空白行并返回该 ID。
<?php
// Independent configuration
require 'medoo.php';
$database = new medoo(array(
// required
'database_type' => 'mysql',
'database_name' => 'db',
'server' => 'server',
'username' => 'user',
'password' => 'pw'
));
$database->insert("properties", array(
"name" => $_POST['name'],
"address" => $_POST['address'],
"address2" => $_POST['address2'],
"city" => $_POST['city'],
"state" => $_POST['state'],
"zip" => $_POST['zip'],
"lat" => $_POST['lat'],
"lng" => $_POST['lng'],
"website" => $_POST['website']
));
$last_id = $database->insert("properties", array(
"propertyId" => "propertyId"
));
$propertyId = array(propertyId => $last_id);
echo json_encode($propertyId);
?>