0

Is there any function I can use to get the last inserted value in my column thread_id?

$result =  DB::insert("Insert Into $this->table (thread_id, sender_id, subject, message, date_sent)
                Select COALESCE(max(thread_id),0)+1 , ? , concat('Re: ',subject), ? , now() FROM $this->table Limit 1",array( $sender_id  ,  $message) );

something like insertGetId

Snippet
  • 1,522
  • 9
  • 31
  • 66

1 Answers1

1

You'll have to perform another query yourself:

$id = DB::table($this->table)->insertGetId('...');

$thread_id = DB::table($this->table)->where('id', $id)->pluck('thread_id');
Joseph Silber
  • 214,931
  • 59
  • 362
  • 292