I'm not able to display data in View
.
Model bank
class ModelBanco extends CI_Model
{
public $em;
public $senha;
public function __construct(){
parent::__construct();
}
function get_user(){
$this->db->select('*');
$this->db->from('tb_user');
$this->db->where('email','magno');
return $this->db->get()->result();
}
}
WelcomeController
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index() {
$this->load->model('ModelBanco','',TRUE);
$data['query']= $this->ModelBanco->get_user();
$this->load->view('welcome_message',$data);
}
}
Welcome_message View
<html>
<head>
</head>
<body>
</body>
</html>
Database has been configured in the / config / database archiver
host='localhost';
username='root';
password='';
database='bd_imobiliaria';
The table inside the bank is tb_user
and field email varchar(255)
, there is a record with the data "magno". I would like to display the records on the screen with codeigniter in MVC just for testing. I added in my View
the suggested code snippet.
echo $query->email;
But this error is appearing.
@rray Severity: Notice
Message: Trying to get property of non-object
Filename: views / welcome_message.php
Line Number: 69
Backtrace:
File: C: \ xampp \ htdocs \ ci_imobiliaria \ application \ views \ welcome_message.php Line: 69 Function: _error_handler
File: C: \ xampp \ htdocs \ ci_imobiliaria \ application \ controllers \ Welcome.php Line: 27 Function: view
File: C: \ xampp \ htdocs \ ci_imobiliaria \ index.php Line: 292 Function: require_once
I've done some research on non-object
.