Data is inserted by calling the insert method it expects the table name followed by an array of key and values to insert in to the database.

$data = [
    'firstName' => 'Joe',
    'lastnName' => 'Smith',
    'email' => ''
$db->insert('users', $data);

The insert automatically returns the last inserted id by returning 'lastInsertId' to collect the id:

$id = $db->insert('users', $data);

Help support the blog so that I can continue creating new content!

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2022 DC Blog. All code MIT license. All rights reserved.