Welcome Guest, Not a member yet? Register   Sign In
How use more models in one controller?
#1

[eluser]Pitrsonek[/eluser]
Hello,
I use CakePHP but today I start test CI.
I have one question, how i can use more models in one controller and call function which use db object.

I traid this code:
In autoload.php i have setting $autoload['libraries'] = array('database');

User Controller
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();
        
        $query2 = $this->db->query('SELECT * FROM POSTS');
        $data['query2'] = $query2->result();        
        $this->layout->view('welcome_message', $data);
    }
}
?>

When i show data from $data['query'] and $data['query2'] with var_dump it show same data. Data in $data['query'] == $data['query2']; But it is bad because Im sure dada must be differential.

I dont know how solve this problem.

THX Pitrsonek Czech Republic


Messages In This Thread
How use more models in one controller? - by El Forum - 12-27-2007, 03:14 PM
How use more models in one controller? - by El Forum - 12-27-2007, 04:12 PM
How use more models in one controller? - by El Forum - 12-27-2007, 04:27 PM
How use more models in one controller? - by El Forum - 12-27-2007, 04:41 PM
How use more models in one controller? - by El Forum - 12-27-2007, 04:49 PM
How use more models in one controller? - by El Forum - 12-28-2007, 10:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB