How does zend obtain the ID of the primary key that just inserted a piece of data? ------ Solution -------------------- $ lastid $ db-& gt; lastInsertId (); in this way, we can obtain the latest id value ------ solution ------------------ to explore how to obtain the primary key id value of the data just inserted? ------ Solution --------- zend obtains the ID of the inserted data
How do I obtain the primary key id value of the inserted data?
------ Solution --------------------
$ Lastid = $ db-> lastInsertId ();
In this way, you can obtain the latest id value.
------ Solution --------------------
Discussion
How do I obtain the primary key id value of the inserted data?
------ Solution --------------------
PHP code
/// Insert into round_table // (noble_title, first_name, favorite_color) // VALUES ("King", "Arthur", "blue "); //// create a $ db object and then... // Construct an insert array in the format of "column name" => "data" and insert a data row $ row = array ('noble _ title' => 'King ', 'First _ name' => 'Arthur ', 'Favorite _ color' => 'blue',); // Insert a data table $ table = 'round _ table '; // I insert data rows and return the number of rows $ rows_affected = $ db-> insert ($ table, $ row); $ last_insert_id = $ db-> lastInsertId ();