我正在尝试MySQL
使用CodeIgniter
PHP 框架在 中动态创建表:
if($colname != ''){
$str = "CREATE TABLE IF NOT EXISTS $colname (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), site_id INT NOT NULL, name BLOB NOT NULL)ENGINE=INNOBD;";
$query = $this->db->query($str);
当我从MySQL
命令提示符执行它时,它完美地创建了表。但是,如果它通过 完成CodeIgniter
,我会收到以下错误:
<body>
<div id="container">
<h1>A Database Error Occurred</h1>
<p>Error Number: 1064</p><p>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 ''tc 11' (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), site_id INT NOT NULL, ' at line 1</p><p>CREATE TABLE IF NOT EXISTS 'tc 11' (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), site_id INT NOT NULL, name BLOB NOT NULL)ENGINE=INNOBD;</p>
这里发生了什么?谢谢