Zend obtains the ID of the inserted data

Source: Internet
Author: User
How does zend obtain the ID of the primary key that just inserted a piece of data? ------ Solution ------------------ $ lastid $ db-& gt; lastInsertId (); then you can get the latest id value ------ solution ------------------ reference: how do I obtain the primary key id value of the inserted data? Positive solution ...... Top .... -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 --------------------
Reference:
How do I obtain the primary key id value of the inserted data?

Positive solution ...... Top ....
------ Solution --------------------

//
// Insert into round_table
// (Noble_title, first_name, favorite_color)
// VALUES ("King", "Arthur", "blue ");
//

// Create a $ db object and then...
// Insert an array and insert data rows in the format of "column name" => "data"
$ Row = array (
'Noble _ title' => 'King ',
'First _ name' => 'Arthur ',
'Favorite _ color' => 'blue ',
);

// Insert 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 ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.