请帮助我无法在 medoo 中获取最后插入的 ID
下面是我的代码:
<?php header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET,OPTIONS,POST,PUT,DELETE'); header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); require 'vendor/autoload.php'; $app = new\Slim\Slim(); $app->container->singleton('db',function () use ($app) { return new medoo([ 'database_type' =>'pgsql', 'database_name' =>'emergency', 'server'=>'localhost', 'username' =>'postgres', 'password' => 'root', 'charset' => 'utf8', 'option' =>[ PDO::ATTR_CASE=>PDO::CASE_NATURAL ] ]); }); $app->db->post('/getinfo',function() { $body = $app->request->post(); $app->db->insert("emergencymessages", [ "message" =>$body["msg"], "createdby"=>$createdby ]); });
现在我想获取紧急消息表的最后插入 id 我怎么能得到它?