MohammedAttya started a new conversation Disconnect And Reconnect Laravel Database Connection
my app run about 2 min per execution most of them on calling outside apis called in one place without talking to db.
I want to close the database connection and reOpen it after finish apis calls
but it throw exception after this while begin a transaction
getPDO() return null
@Cronix this is the function that laravel using for insertGetId() and it is returning last inserted ID for current session
I had issue with getting the correct IDs I found that MySQL returning the first ID of bulk insetred rows (not the last one as I expected)
I solved this problem using
app('db')->getPdo()->lastInsertId() after insert so I got the last inserted id
I want to insert bulk on database and get rows id (first one, last one or all rows)
I tried insertGetId but it took only one row per time
Is there any way to get the query object of insert or run anonymous function with it to run `$id = $query->getConnection()->getPdo()->lastInsertId($sequence);
` on it ?
@klick I updated the thread so my question will be clear