Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在mysql表名中使用(-)破折号_Mysql - Fatal编程技术网

在mysql表名中使用(-)破折号

在mysql表名中使用(-)破折号,mysql,Mysql,我想备份数据库时出错 A Database Error Occurred Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-01-000001' at line 1 SELECT * FROM temp_01-01-000001 F

我想备份数据库时出错

A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-01-000001' at line 1

SELECT * FROM temp_01-01-000001

Filename: F:\xampp\htdocs\erp_zaara\system\database\DB_driver.php

Line Number: 330

有没有办法用表名temp_01-01-000001解决这个问题。

您必须添加引号,因为表名包含数字。我认为下面的查询将起作用

SELECT * FROM `temp_01-01-000001`

您可以编辑文件/system/database/drivers/mysql/mysql\u utility.php的第132行

发件人:

$query = $this->db->query("SELECT * FROM $table");
致:


没有手动查询。它的codeigniter dbutil用于数据库备份,终于找到了一种方法!我的一般建议是:不要使用包含非法字符的表名,这样就需要引用。他们比他们值得的麻烦多。这只是另一个例子。破折号-它不是非法字符,但必须用反勾号“”引用。见:我认为约翰维的评论将是继续下去的方式;由于许多原因,手动修改驱动程序存在问题。
$query = $this->db->query("SELECT * FROM `$table`");