我Undefined table data error
在 CodeIgniter 中得到一个,但不知道为什么。当我第一次尝试从 CI 网站回显示例表时,一切正常:
function ajaxAvgSalePriceTable(){
$this->load->library('table');
$query = array(
array('Name', 'Color', 'Size'),
array('Fred', 'Blue', 'Small'),
array('Mary', 'Red', 'Large'),
array('John', 'Green', 'Medium')
);
echo $this->table->generate($query);
}
但是,当我尝试使用自己的查询时,我得到了Undefined table data
错误。这是导致错误的代码:
function ajaxAvgSalePriceTable(){
$this->load->library('table');
$muni = $this->input->POST('muni');
$query = "SELECT SaleYear AS Y, NewSaleType AS T, count(*) AS C, tblsales.Municipality AS M, format((sum(SalePrice) / sum(Quantity1)),0) AS R FROM tblsales WHERE tblsales.SaleYear > 2007 AND tblsales.Quantity1 > 2000 AND (tblsales.NewSaleType = 'Industrial') AND tblsales.Municipality = '".$muni."' GROUP BY T,M,Y ORDER BY T,M,Y";
echo $this->table->generate($query);
}
谁能看到我可能做错了什么?我已经单独测试了这个查询,它在其他地方工作正常,只是在这里不工作。