Level 50
You will find everything here:
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to build a query in laravel from the given SQL query.
select
if(count(*) = 0, 'insert', if(count(*) = 1, 'update', if(count(*) > 1, 'multiple records found',
'nothing'))) as required_action
from
test_importer
where 1
and record_id = 1881
and date_time = "1999-21-19 22:33:18";
This one helped me.
$users = DB::select('select if(count(*) = 0, \'insert\', if(count(*) = 1,
\'update\', if(count(*) > 1, \'multiple\', \'nothing\'))) as required_action from
test_importer where record_id = ? and date_time = ? ',
[$row['record_id'],$row['date_time']]);
Please or to participate in this conversation.