[eluser]LeonardoRaygoza[/eluser]
Im having a problem, I set on the database.php the credentials to mY localhost, Im trying to work on mysql, I followed the user-guide.
I created a new model, then the function.
<?php
class Blogmodel extends Model {
function Blogmodel
{
parent::Model();
$this->load->database();
}
function get_entries()
{
$query = $this->db->query(‘Select * from mytable’);
}
}
?>
then I’m calling the model from controller.
<?php
class Blog extends Controller{
function Blog()
{
parent::Controller();
}
function index()
{
$this->load->model(‘blog_model’);
$data[‘query’] = $this->blog_model->get_entries();
$this->load->view(‘blog_view’, $data);
}
}
?>
this is my view code:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html >
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<title>Leo’s Blog</title>
</head>
<body>
<h1>This is my blog!</h1>
<?php
foreach($query->result() as $row)
{
echo $row->id_usuario;
echo $row->nombre;
echo $row->usuario;
echo $row->password;
echo $row->email;
}
?>
</body>
</html>