Implement Auto-Increment IDs in PHP's PDO Interface


show more Implementing auto-increment IDs provides you with in-depth training on Developer. Taught by Bill Weinman as part of the MySQL Essential Training show less
please wait ...

Implementing auto-increment IDs

When a new row is inserted into a table in a relational database, you often need to know the value of the id column for the new row so that it can be used in another table or for interactive forums or other purposes. MySQL provides a function called last insert id that provides the most recently generated value of an auto-increment column. For example, here in this insert album SQL function you notice we have this simple query inserted into the album. The question marks are for the parameters and those parameters are filled in here in the execute call with title artist, label, and released.

And then down here there's a call to lastInsertId. It has a slightly different form for the. Postgress database but it gets the last inserted ID. It'll get the ID of this column after it's been inserted into the database and that's returned. It's eventually used in this album edit, function up here. Which gets past that ID for building the Album Edit form. And so, if I come out here to the applica...

Implementing auto-increment IDs
Video duration: 2m 3s 4h 24m Beginner

Viewers:

Implementing auto-increment IDs provides you with in-depth training on Developer. Taught by Bill Weinman as part of the MySQL Essential Training

Subject:
Developer
Software:
MySQL
Author:
please wait ...