I tried to truncate a table but why is it not working? must something wrong in the database query?
$sql = \"TRUNCATE TABLE `table_name`\";
$result = $connec
By the MySQL Reference Manual
http://dev.mysql.com/doc/refman/5.0/en/truncate-table.html
You can only delete one table at a time using TRUNCATE.
You could try executing multiple queries in one PHP query by using a ";" delimiter between them.
thanks for the help guys! here is my answer,
# truncate data from all table
# $sql = "SHOW TABLES IN 1hundred_2011";
# or,
$sql = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE '".DB_NAME."'";
# use the instantiated db connection object from the init.php, to process the query
$tables = $connection -> fetch_all($sql);
//print_r($tables);
foreach($tables as $table)
{
//echo $table['TABLE_NAME'].'<br/>';
# truncate data from this table
# $sql = "TRUNCATE TABLE `developer_configurations_cms`";
# use the instantiated db connection object from the init.php, to process the query
# $result = $connection -> query($sql);
# truncate data from this table
$sql = "TRUNCATE TABLE `".$table['TABLE_NAME']."`";
# use the instantiated db connection object from the init.php, to process the query
$result = $connection -> query($sql);
}
You have a couple different option.