【发布时间】:2013-06-15 17:58:22
【问题描述】:
我的一个模型中有以下 Active Record 模式:
$this->db->get('names');
$this->db->like('name', $name);
$this->db->where('ratio >=', 0.75);
$this->db->order_by('ratio', 'desc');
$query = $this->db->get();
这给了我一个语法错误:
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 `ratio` >= 0.75 AND `name` LIKE '%JORDAN%' ORDER BY `ratio' at line 2
返回的完整语句是:
SELECT * WHERE `ratio` >= 0.75 AND `name` LIKE '%JORDAN%' ORDER BY `ratio` desc
我不知道为什么我的表 names 没有显示,因为我正在调用 $this->db->get('names'); 应该产生 SELECT * FROM names,它只是没有返回错误吗?这个陈述有什么问题,我应该怎么做才能更正我的 Active Record 调用?
【问题讨论】:
标签: php mysql codeigniter activerecord