Db::insertOrUpdate

Usage

void Db::insertOrUpdate(string $table_name, [ ... $args ])

Description

Insert or update a record into a database table.

Parameters

Parameter Required Type Description
$table_name Yes string The table name to insert or update record within.
$args No desc=

Examples

Insert or Update



// Add new user $this->db->insertOrUpdate('users', [ 'name' => 'John Smith', 'email' => 'john@domain.com' ]); // Get userid $userid = $this->db->insertId(); // Update the existing record $this->db->insertOrUpdate('users', [ 'id' => $userid, 'name' => 'Mike Smith'', 'email' => 'mike@domain.com' ]); // This will result in one record with the name 'Mike Smith'.

See Also