Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lars-Janssen's avatar

Why does updateGetId not exists on the query builder?

Hi,

I know insertGetId(); exists on the query builder. But why is there no updateGetId();? Is there a reason for this or should I make a pull request because I need it ! :)

https://laravel.com/api/5.3/Illuminate/Database/Query/Builder.html

Thanks!

0 likes
4 replies
Snapey's avatar

because if you are updating then you already know the id !

Lars-Janssen's avatar

@Snapey that's not entirely true :)

For example i've this:

DB::connection('shop')->table('cata')
             ->select('id')
             ->where(['sku' => $sku])
             ->update([
                'content'    => 'bla bla bla',
             ]);

maybe I should make a pull request for updateGetId();

Snapey's avatar
Snapey
Best Answer
Level 122

and you want to know which row was updated?

I doubt thats possible because the database will update the matching row(s), the return value is the number of rows not the ones that are affected.

Your question implies that only one row was updated but that may not be the case.

1 like

Please or to participate in this conversation.