我有下面的代码,我无法弄清楚CodeIgniter为什么要为它生成的查询添加一个额外的通配符。为什么CodeIgniter为这个查询添加一个额外的星号?
代码
class Foo_Model extends CI_Model {
private $table = 'foo';
public function get_all_foos() {
$table = $this->table;
$this->db->select("$table.*")->from($table);
return $this->get()->result();
}
}
而且我得到以下错误:
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 '* FROM (
foo
,foo
)' at line 1SELECT
foo
.*, * FROM (foo
,foo
)
为什么会出现查询产生不正确的?
您是否尝试过这个查询没有方法链接?你是否还尝试过不将类属性'$ table'分配给一个局部变量,而是实际上只是在from子句中引用'$ this - > $ table'?在from子句中显示两个表引用的事实绝对是奇怪的。然而,正如Catfish提到的那样,如果选择全部,那么'select()'方法并不是真的需要。 – Wolf 2012-08-10 21:50:14