Welcome Guest, Not a member yet? Register   Sign In
single ds with MVC?
#1

[eluser]Matthew90[/eluser]
Hello,

today I have started to work with CI and my first impression is really good :-)
As this is my first job with a framework, the MVC-Model and strict OOP-Programming is new for me.
Now I have an problem with the MVC-Model.
It concerns the following...
I want to return a single data set... without oop no problem:
Code:
$this->db->where(array('id' => $this->uri->segment(3)));
        $query = $this->db->get('projects');
        
        
        if ($query->num_rows() > 0) {
            $row = $query->row();
        
               echo $row->id;
               echo $row->description;
                    
           //...
        }
But how can I do it, when I want to work with the model class?
I tried a lot of iddeas but without a result...
At the moment my code is as followed:

project_model.php
Code:
function get_requested_project($where)
    {
        $this->db->where($where);
        $query = $this->db->get('projects');
        
        if ($query->num_rows() > 0) {
            return $query->row();
        }
        else {
            return false;
        }
    }

admin.php
Code:
function insert_project()
    {
        $this->load->model('project_model');
        
        $row=$this->project_model->get_project(array('id' => $this->uri->segment(3)));
        if ($row != false) {
               echo $row->id;
               echo $row->description;
                    
            $this->load->view('project_insert',$data);
        }

I hope you know what I mean in spite of my bad English and I look forward to get an answer ;-)

Greetings

Matthew


Messages In This Thread
single ds with MVC? - by El Forum - 08-25-2007, 12:40 PM
single ds with MVC? - by El Forum - 08-28-2007, 03:18 AM
single ds with MVC? - by El Forum - 08-28-2007, 04:35 AM
single ds with MVC? - by El Forum - 08-28-2007, 11:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB