Laravel Database Insert Request

I am trying to do a simple insert into a database and im getting the following error

call_user_func_array () expects parameter 1 to be a valid callback, no given array or string

The insert code is as follows

DB::insert('insert into users (id, name) values (?, ?)', array(1, 'Dayle'));

This is the main request for laravel, but it will not work why?


+4
source share
1 answer
DB::table('users')->insert(
     array(
            'id'     =>   '1', 
            'name'   =>   'Dayle'
     )
);

or

$values = array('id' => 1,'name' => 'Dayle');
DB::table('users')->insert($values);

But why do you insert an identifier? Should it not increase automatically?

+14
source

All Articles