Solar_Sql_Adapter::insert()

public int Solar_Sql_Adapter::insert ( string $table , array $data )

Inserts a row of data into a table.

Parameters

  • (string) $table: The table to insert data into.

  • (array) $data: An associative array where the key is the column name and the value is the value to insert for that column.

Returns

  • (int) The number of rows affected, typically 1.

Description

Inserts a row of data into a table.

Automatically applies quote() to the data values for you.

For example:

<?php
$sql = Solar::factory('Solar_Sql');

$table = 'invaders';
$data = array(
    'foo' => 'bar',
    'baz' => 'dib',
    'zim' => 'gir'
);

$rows_affected = $sql->insert($table, $data);
// calls 'INSERT INTO invaders (foo, baz, zim) VALUES ("bar", "dib", "gir")'


Local