• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
database problem

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.


class Blogmodel extends Model {

function Blogmodel

function get_entries()
$query = $this->db->query(‘Select * from mytable’);


then I’m calling the model from controller.


class Blog extends Controller{

function Blog()

function index()
$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”>
&lt;html &gt;
&lt;meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” /&gt;
&lt;title&gt;Leo’s Blog&lt;/title&gt;


<h1>This is my blog!</h1>

foreach($query->result() as $row)
echo $row->id_usuario;
echo $row->nombre;
echo $row->usuario;
echo $row->password;
echo $row->email;



One thing jumped right out when I looked at your code. You named your model "Blogmodel" and you refer to it as "blog_model" in your controller.

$data[‘query’] = $this->blog_model->get_entries();

Fix that first. Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.