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

konrms's avatar

How to update oracle table using laravel eloquent query

Hi guys,

I have created a table called PROG_TITLE with 3 data fields (PR_ID, PR_TITLE and PR_INDEX). I have populated it with values and I want to update PR_INDEX values with 1 if PR_TITLE is not null.

How can I do it with eloquent query?

The query in oracle is

UPDATE PROG_TITLE SET PR_INDEX = '1' WHERE PR_TITLE IS NOT NULL;

0 likes
7 replies
jlrdw's avatar

With knowing that eloquent converts to regular sql at run time anyway, why not just use normal queries. Just my 2 cents.

jlrdw's avatar

I haven't messed with oracle for years, and when I did it was coldfusion I programmed in.

I had to write code to calc pagination. Does modern oracle have any type LIMIT, OFFSET clause yet.

I know sql server 2014 has that now. Now you have me curious.

You can still return results from a model, or use VC, much like some did with java, just a view and servlet. Depends on how large app is and the section of app in question.

New asp.net razor has just MV. Model and controller combined. It's pretty good.

konrms's avatar

@JLRDW - I'm too novice with laravel and eloquent. I'll try to do it with normal query (I guess using DB::raw)...

jlrdw's avatar

DB::raw)...

Bind your parameters, give me second I am putting up some links, but may not work with oracle.

konrms's avatar
konrms
OP
Best Answer
Level 1

My solution that worked is this. In fact I populated table with all PR_INDEX values set to 1 by default and zeroed them conditionally. The function editor is inside controller obviously.

@jlrdw Thanks a lot for your resources!

public function editor (Request $ppp) { $pppvar = $ppp -> get('identity');

    DB::table('prog_title')
        ->where('pr_id', $pppvar)
        ->update(array('pr_index' => 0));
        
    return view ('return'); 

}

1 like

Please or to participate in this conversation.