Welcome Guest, Not a member yet? Register   Sign In
Syntax in function does not work
#14

I dont understand exactly what you try to do. You have to go with the MVC pattern with CI. So all of your database stuff should organized in a model like

PHP Code:
class Example_model extends CI_Model {
    function 
__construct()
    {
    }

    public function 
get($table$id false)
    {
        if (
$id)
        {
            
$this->db->where('id'$id);
        }
        
$query $this->db->get($table);
        if(
$query->num_rows() > 0)
        {
            return 
$query->result_array();
        }
        return 
false;
    }

    
// etc.


Then in all of your controller files you can call your model methods like that

PHP Code:
class Example extends CI_Controller {

    public function 
__construct()
    {
        
parent::__construct();
        
$this->load->model('example_model');
    }

    public function 
index()
    {
       
$this->example_model->get('users');
    }


Reply


Messages In This Thread
Syntax in function does not work - by lkudlacek - 11-29-2014, 09:23 AM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 10:26 AM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 04:36 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 04:50 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 04:54 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 05:10 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 05:25 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 05:45 PM
RE: Syntax in function does not work - by Rufnex - 12-01-2014, 03:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB