我看过其他主题,但我无法弄清楚这里有什么问题。例如,如果我用简单的 SELECT * 替换 TRUNCATE 查询,我会得到结果。但这返回错误。我从这个主题复制了以下代码,希望得到结果:PHP & MySQL: Truncate multiple tables
我正在通过 AMFPHP 做到这一点。
# the host used to access DB
define('DB_HOST', 'localhost');
# the username used to access DB
define('DB_USER', 'usr');
# the password for the username
define('DB_PASS', '***');
# the name of your databse
define('DB_NAME', 'name');
//$connection = new __database(DB_HOST,DB_USER,DB_PASS,DB_NAME);
$connection = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "TRUNCATE TABLE `books`";
$result = $connection->query($query);
if($result)
{
return $result;
}
else
{
return false;
}