35 lines
985 B
PHP
35 lines
985 B
PHP
<?php
|
|
|
|
class ToolsController extends BaseController {
|
|
|
|
public function _handlePre()
|
|
{
|
|
parent::_handlePre();
|
|
if (SERVER_ENV == _ONLINE) {
|
|
die("can't create ToolsController");
|
|
return;
|
|
}
|
|
}
|
|
|
|
public function clearDB()
|
|
{
|
|
global $g_conf_mysql_cluster;
|
|
foreach ($g_conf_mysql_cluster as $mysql_conf) {
|
|
$conn = new phpcommon\Mysql(array(
|
|
'host' => $mysql_conf['host'],
|
|
'port' => $mysql_conf['port'],
|
|
'user' => $mysql_conf['user'],
|
|
'passwd' => $mysql_conf['passwd'],
|
|
'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id']
|
|
));
|
|
$tables = $conn->execQueryAsArray('show tables;');
|
|
foreach ($tables as $table) {
|
|
$tblName = $table[0];
|
|
$conn->execScript("DELETE FROM {$tblName};",
|
|
arary());
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|