W
W
WebDev2016-10-30 03:01:06
Laravel
WebDev, 2016-10-30 03:01:06

Insert ignore in laravel?

You need to insert a lot of records, in the usual case it looks like this:

$data = [
    ['title1', 'text1'],
    ['title2', 'text2']
];

Model::insert($data);

How to add IGNORE to such query?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Petr Flaks, 2016-11-01
@neluzhin

Try methods firstOrNew()or firstOrCreate(). But they allow you to add only one record at a time. See Inserting & Updating Models > Other Creation Methods .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question