PDO Delete Function delete database operation using GOModel


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


                                $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

More Examples

                                //Example 1
                                $GOModel->where("orderId", 7);

                                //Example 2
                                $GOModel->where("firstName", 'john');
                                $GOModel->where("lastName", 'johny');


Record will be deleted in database


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