Description
Truncate table function allows to truncate a table from database by specifying the table name.
Please note that sqlite doesn't support truncate command
Function Defination
void function truncateTable($dbTableName);
Parameters Details
| Details | Type | Example |
|---|---|---|
| $dbTableName - table name to be truncated | string | e.g. "emptable" |
Examples
$pdomodel = new PDOModel(); //create object of the PDOModel class
$pdomodel->connect("localhost", "root", "", "pdocrud");//connect to database
/* Get all tables function */
$pdomodel->truncateTable("order_meta");
More Examples
//Example 1
if($pdomodel->truncateTable("wp_posts"))
echo "table truncated";;
Result/Output
Return true if table truncated successfully
Debug
| Option | Details | Example |
|---|---|---|
| $pdomodel->getLastQuery(); | Return last query executed | TRUNCATE TABLE `wp_posts` |
| print_r($pdomodel->error) | Print errors (if any) |