Search
 
SCRIPT & CODE EXAMPLE
 

SQL

laravel 8 insert multiple rows

$array = [
     ['value' => "value1", 'status_id' => 1],
     ['value' => "value2", 'status_id' => 2]
];

ModelName::insert($array);
// or
DB::table('table_name')->insert($array);
Comment

insert multiple rows laravel

$data = [
    ['user_id'=>'Coder 1', 'subject_id'=> 4096],
    ['user_id'=>'Coder 2', 'subject_id'=> 2048],
    //...
];

Model::insert($data); // Eloquent approach
DB::table('table')->insert($data); // Query Builder approach
Comment

how to insert multiple rows in mysql using laravel

/*
It is really easy to do a bulk insert in Laravel with or without the query builder.
You can use the following official approach.
*/


Entity::upsert([
    ['name' => 'Pierre Yem Mback', 'city' => 'Eseka', 'salary' => 10000000],
    ['name' => 'Dial rock 360', 'city' => 'Yaounde', 'salary' => 20000000],
    ['name' => 'Ndibou La Menace', 'city' => 'Dakar', 'salary' => 40000000]
], ['name', 'city'], ['salary']);
Comment

PREVIOUS NEXT
Code Example
Sql :: sql server function to calculate a percentage 
Sql :: joining tables in sql 
Sql :: right join 
Sql :: insert set mysql 
Sql :: mysql get auto_increment value 
Sql :: mysql dump database tables only 
Sql :: CREATE table schema using select 
Sql :: add column mysql 
Sql :: sqlalchemy _in array sqlite 
Sql :: update all columns in one update 
Sql :: mysql_union 
Sql :: table user postgres 
Sql :: sql and or 
Sql :: primary key auto increment in postgresql 
Sql :: sql where statement 
Sql :: oracle sysdba connect as another user 
Sql :: sql joins in python 
Sql :: how to count codition 
Sql :: how to select only first 3 characters in sql 
Sql :: SQL Query Records Using Dates 
Sql :: How to concatenate text from multiple rows into a single text string in SQL Server 
Sql :: A good way of running a SQL query in JDBC using a parameterized statement 
Sql :: insert statement with $1 
Sql :: open database restricted mode oracle 
Sql :: sql agent jb is enabled query 
Sql :: multiple row join 
Sql :: plsql select intop 
Sql :: greater than and less than in mysql query 
Sql :: oracle test if 0 
Sql :: mysql streaming example 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =