PDO truncate table Function truncate a table from database using GOModel

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

  
                                $GOModel = new GOModel(); //create object of the GOModel class
                                $GOModel->connect("localhost", "root", "", "database");//connect to database
                                /* Get all tables function */
                               $GOModel->truncateTable("order_meta");           
                            

More Examples

 
                                //Example 1
                                if($GOModel->truncateTable("wp_posts"))
                                    echo "table truncated";;
                            

Result/Output

Return true if table truncated successfully

Debug

Option Details Example
$GOModel->getLastQuery(); Return last query executed TRUNCATE TABLE `wp_posts`
print_r($GOModel->error) Print errors (if any)