4
Via PDO
, can do the TRUNCATE
(English) of a table as follows:
// Matriz de definições
$dbcon_new = array(
"host" => "localhost",
"dbname" => "bubu",
"username" => "super_dragon",
"password" => "balls"
);
// estabelece a ligação
$dbh = new PDO(
'mysql:host='.$dbcon_new['host'].';dbname='.$dbcon_new['dbname'].';',
$dbcon_new['username'],
$dbcon_new['password'],
array(
PDO::ATTR_PERSISTENT => false,
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
)
);
// esvazia a tabela xpto
$dbh->exec("TRUNCATE TABLE xpto");
Question
How can I in a single execution TRUNCATE
to multiple tables?
@Gabrielgartz I changed the phrase of the question section that had been edited because it was really strange (at least for a Portuguese from Portugal).
– Zuul
Yes, now it is clearer, I speak Brazilian Portuguese and I was having difficulty understanding the question why I had edited, but this way it became clear in both dialects. :)
– Gabriel Gartz