我是codeigniter编程的新手.当我尝试连接数据库并从表中检索数据时,我发现错误如:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_DB_mysql_result::$result
Filename: models/haii.php
Line Number: 15.
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/getquery.php
Line Number: 2
Run Code Online (Sandbox Code Playgroud)
我使用此代码使用codeigniter连接数据库:
<?php
class product extends CI_Controller
{
function __construct()
{
}
function getall()
{
$this->load->model('haii');
$data['query']=$this->haii->you();
$this->load->view('getquery',$data);
}
}
?>
Run Code Online (Sandbox Code Playgroud)
<?php
class haii extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
function you()
{
$query=$this->db->get('member');
return $query->result;
}
}
?>
Run Code Online (Sandbox Code Playgroud)
<?php …Run Code Online (Sandbox Code Playgroud)