MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to Update and Delete Data From Database table using Tinker.

How to Update Data in the Database table.

We use the update command to update the data in the database table.

Syntax

Tinker update syntax: DB::table(Table_Name)->where(id, ID_Value)->update([Key1=>Key1_Value, Key2=>Key2_Value])

Suppose, I want to update my row whose ID no. is 20. I’m added my id and id no. in where condition and the data which I want to update is written under Update method. After hitting enter, if it returns 1 then it’s true, means data updated in the database. See below:-

PhpMyAdmin table before and after a Tinker update changes row 20 name and email, returning 1

The above command shows that I updated the E-mail and Name of the row whose id is 20.

Note:- If we can’t write where condition, then it will update the given data to all the E-mail and Names.

How to Delete Data From Database table.

We use the Delete command to Delete the data from the database table.

Syntax

Tinker delete syntax: DB::table(Table_Name)->where(id, ID_Value)->delete()

Suppose, I want to Delete my row whose ID no. is 20. I’m added my id and id no. in where condition calls Delete method. After hitting enter, if it returns 1 then it’s true, means data Deleted from the database. See below:-

PhpMyAdmin table before and after a Tinker delete command removes row 20, returning 1

The above command shows that I deleted the row whose id is 20.

Note:- If we can’t write where condition, then it will Delete all the data from the table.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

How to merge two or multiple tables to each other in the Laravel PHP Framework? (Part-2)

How to merge two or multiple tables to each other in the Laravel PHP Framework? Part-1 Part-3 Step 1. Go to app/Country.php. Now, we need to list…

Read More

CRUD Operation Using Model in Laravel.

Inserting data in Database through Model. (Click to Open) Read, Update, and Delete data through Model. (Click to Open) Sushant Kumar With MotoShare.in, you can book a…

Read More

Read, Update, and Delete data through Model.

Read Data from Database through Model First, we have to connect our model and database in our controller. For that we use below code in our controller:-…

Read More

Inserting data in Database through Model.

There are many methods for inserting data in database through Model. See below:- Migration is common in all methods in which we defined the table name and…

Read More

Python Tutorials: Database operations using python – mysql

This tutorial connects Python to MySQL with the official mysql-connector-python driver and runs the full set of CRUD operations: create a database and table, then insert, read,…

Read More

What is Laravel and use cases of Laravel?

What is Laravel? Laravel is an open-source, free PHP web framework designed for the development of web applications following the model-view-controller (MVC) architectural pattern. It was generated…

Read More