我發佈了一個新的行到數據庫,但想要返回新的自動遞增的ID在使用medoo的響應中。這似乎正在生成一個新的空白行並返回該ID。得到最後一個自動遞增的ID與medoo
<?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);
?>
那麼,什麼是問題:
此代碼是從官方資料爲準? – zerkms