Jump to content

Updating rows in the DB or create new ones


safemode

Recommended Posts

hi

i have create modules that need to Updating rows in the DB or create new ones


  if (isset($_POST["pid"])) {
    try {

        $insert_array = [

            "pid" => $_POST["pid"],
            "purchase" => $_POST["price"]

        ];
        Capsule::table('rasanegarbulkprice')
            ->insert($insert_array);
    } catch(\Illuminate\Database\QueryException $ex){
        echo $ex->getMessage();
    } catch (Exception $e) {
        echo $e->getMessage();
    }
  }

this is my code that i use for inserting

but i want to change it to IF exist update row or create it

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated