Habari\DatabaseConnection::insert PHP Метод

insert() публичный Метод

Inserts into the specified table values associated to the key fields
public insert ( string $table, array $fieldvalues ) : boolean
$table string The table name
$fieldvalues array An associative array of fields and values to insert
Результат boolean True on success, false if not DB::insert( 'mytable', array( 'fieldname' => 'value' ) );
    public function insert($table, $fieldvalues)
    {
        ksort($fieldvalues);
        $fields = array_keys($fieldvalues);
        $values = array_values($fieldvalues);
        $query = "INSERT INTO {$table} ( " . implode(', ', $fields) . ' ) VALUES ( ' . implode(', ', array_fill(0, count($values), '?')) . ' )';
        // need to pass $table on to the $o singleton object;
        $this->current_table = $table;
        return $this->query($query, $values);
    }