Description
GOModel delete function provides a simplest way to delete the data from database.
You need to pass table name from which you need to delete data and specify where condition to select records to be deleted. Please note that you must set where
condition to delete specific data else all data will be deleted.
Function Defination
void function delete($dbTableName);
Parameters Details
Details | Type | Example |
---|---|---|
$dbTableName - Table name to delete records | string | Any table name like "orderTable", "wp_posts" etc |
Examples
$GOModel = new GOModel(); //create object of the GOModel class $GOModel->connect("localhost", "root", "", "database");//connect to database /* Delete function */ $GOModel->where("orderId", 7);//setting where condition $GOModel->delete("order");
More Examples
//Example 1 $GOModel->where("orderId", 7); $GOModel->delete("order"); //Example 2 $GOModel->where("firstName", 'john'); $GOModel->where("lastName", 'johny'); $GOModel->delete("emp");
Result/Output
Record will be deleted in database
Debug
Option | Details | Example |
---|---|---|
$GOModel->getLastQuery(); | Return last query executed | DELETE FROM `emp` WHERE `firstName`= ? AND `lastName`= ? |
print_r($GOModel->error) | Print errors (if any) | |
$GOModel->rowsChanged; | Return Rows created/changed | 1 |