[eluser]tonanbarbarian[/eluser]
i would try the following change
Code:
<?php
class User extends Controller {
function __construct(){
parent::Controller();
$this->load->library('layout', 'layout_client');
}
function index(){
$query = $this->db->get('users');
$data['query'] = $query->result();
$query->free_result();
unset($query);
$query2 = $this->db->query('SELECT * FROM POSTS');
$data['query2'] = $query2->result();
$query2->free_result();
unset($query2)
$this->layout->view('welcome_message', $data);
}
}
This will free up the results from the query.
As for loading a model that is simple
Code:
$this->load->model('users');
You can call it is many times as needed to load as many models as you need.
So in your example you could do something like the following
Code:
<?php
class User extends Controller {
function __construct(){
parent::Controller();
$this->load->library('layout', 'layout_client');
}
function index(){
$this->load->model('users');
$data['query'] = $this->users->getAll();
$this->load->model('posts');
$data['query2'] = $this->posts->getAll();
$this->layout->view('welcome_message', $data);
}
}
application/models/users.php
Code:
<?php
class Users extends Model {
function Users() {
parent::Model();
} // Users
function getAll() {
$query = $this->db->get('users');
$result = $query->result();
$query->free_result();
unset($query);
return $result;
} // getAll()
} // class Users
application/models/posts.php
Code:
<?php
class Posts extends Model {
function Posts() {
parent::Model();
} // Posts
function getAll() {
$query = $this->db->get('posts');
$result = $query->result();
$query->free_result();
unset($query);
return $result;
} // getAll()
} // class Posts