[eluser]Unknown[/eluser]
Model:
Code:
<?php
class Blogm extends CI_Model{
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get()
{
$query = $this->db->get('post', 1);
return $query->result();
}
}
?>
View:
Code:
<h2>
<?php
foreach($query as $a):
echo $a;
endforeach;
?>
</h2>
</body>
</html>
Controller:
Code:
<?php
class Blog extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->model('Blogm','',TRUE);
}
public function index(){
$data['title'] = 'Sblog';
$data['message'] = 'My Sblog';
$data['menu_item'] = array('home','contact');
$this->load->view('headerv.php', $data);
$data['query'] = $this->Blogm->get();
$this->load->view('bodyv.php', $data);
//$this->load->view('sidebarv.php');
//$this->load->view('footerv.php');
}
}
?>
Database:
Code:
id int(11) No None auto_increment
title text
MIME: text/plain latin1_swedish_ci No None
content text
MIME: text/plain latin1_swedish_ci No None
time timestamp on update CURRENT_TIMESTAMP No CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
posted int(1) No 0
Database has only one entry...
Anyone help pls..
This is my error..
Code:
A PHP Error was encountered
Severity: 4096
Message: Object of class stdClass could not be converted to string
Filename: views/bodyv.php
Line Number: 5