PDO Delete Batch Function batch delete database operation using PDOModel

Description

PDOModel batch delete function provides a simplest way to delete the batch of 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 deleteBatch($dbTableName, $where = array());
                                

Parameters Details

Details Type Example
$dbTableName - Table name to delete records string Any table name like "orderTable", "wp_posts" etc
$where - where condition string $where = array(array("empId",70), array("empId",71));

Examples

  
                                $pdomodel = new PDOModel(); //create object of the PDOModel class
                                $pdomodel->connect("localhost", "root", "", "pdocrud");//connect to database
                                /* Delete batch function */
                                //Example 1
                                $where = array(array("empId",70), array("empId",71));
                                $pdomodel->deleteBatch("emp",$where);
                            

More Examples

 
                                //Example 1
                                 $where = array(array("empId",70), array("empId",71));
                                 $pdomodel->deleteBatch("emp",$where);
                            

Result/Output

Record will be deleted in database

Debug

Option Details Example
$pdomodel->getLastQuery(); Return last query executed DELETE FROM `emp` WHERE `empId`= ?
print_r($pdomodel->error) Print errors (if any)
$pdomodel->rowsChanged; Return Rows created/changed 1