【发布时间】:2016-04-20 22:15:40
【问题描述】:
我刚刚使用 CodeIgniter 设置了 DataMapper,并根据需要编写了模型。
但是我似乎遗漏了一些东西,因为当我运行查询时,DataMapper 看不到表名覆盖并认为根本没有表。
有趣的是,如果我删除了覆盖,它会正常工作(尽管有一个错误说自动生成的表格不存在)。
型号代码:
class Activity extends Datamapper {
var $table = 'activity_log';
var $has_one = [
'user'
];
}
控制器代码:
$activity = new Activity(1);
错误:
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 'WHERE `.`id` = 1' at line 2
SELECT * WHERE `.`id` = 1
如上所述,如果我删除 var $tables = 'activity_log';然后它将推迟到应有的查找表“活动”。
【问题讨论】:
标签: php mysql codeigniter datamapper