Skip to content

ProtonDB: Insert

ProtonSite.com edited this page Oct 21, 2018 · 3 revisions

Please read the Setup page before continuing or the code described on this page will not work.

Insert Record

The insert() method takes 2 parameters, a String for the table name, and an array of Key => Value pairs for the columns/fields you wish to insert.

$insert = $db->insert('table', [
    'column_field' => 'value',
    'this' => 'that'
]);

A boolean will be returned indicating the success or failure of the record being inserted.

// Check if record was inserted.
if( $insert ) {
    // Success
} else {
    // Failed
}