我在模型中有以下函数,但是它不断返回:
消息:mysql_fetch_array():提供的参数不是有效的 MySQL 结果资源
我一辈子都想不通为什么。
function getNames() {
$query1 = $this->db->query("SELECT * FROM Device_tbl ORDER BY Manufacturer");
$dev = array();
while($row = mysql_fetch_array($query1))
{
$manu = $row['Manufacturer'];
$mod = $row['Model'];
$dev[] = $manu.' '.$mod;
}
return $dev->result();
}
任何人都可以帮忙吗?
CodeIgniter 的答案是:
$query1 = $this->db->query("SELECT * FROM table");
foreach($query1->result_array() as $row)
{
$manu = $row['column1'];
$mod = $row['column2'];
echo $manu.' '.$mod;
}
return $query1->result();