Welcome Guest, Not a member yet? Register   Sign In
callback from model
#6

[eluser]smith[/eluser]
Maybe you didn't understand me. I am still having all dbase function available in the model:
for example, if i want to repopulate the form, i will do this inside model:
Code:
if (!$this->data['vflag'] && $this->data['action']=="edit")
        {
            $sql = "SELECT * FROM some_table where some_id='".$this->data['some_id']."'";
            $query = $this->db->query($sql);
            if ($query->num_rows()>0)
            {
                $row = $query->row();
                $this->validation->some_id      = stripslashes($row->some_id);
                $this->validation->some_field     = stripslashes($row->some_field);
                $this->validation->some_field_2    = stripslashes($row->soem_field_2);
                         }
                   ..............

my example from first post is only howto for situations where you need to do callback from model, during validation. if you do validation inside model then model will not look for your callback function inside itself but he will go to your controller and look for callback function. that way you would have to have all logic inside model and callback functions inside controller. my solution solves that problem by letting you have all callback functions inside a library, and all logic for forms inside a model, so inside controller you will only do:
Code:
$this->data['form'] = $this->model_name->form_name();

i am sorry, this is best that i can explain in english Sad


Messages In This Thread
callback from model - by El Forum - 10-11-2007, 07:16 AM
callback from model - by El Forum - 10-11-2007, 12:18 PM
callback from model - by El Forum - 10-11-2007, 03:30 PM
callback from model - by El Forum - 10-11-2007, 03:48 PM
callback from model - by El Forum - 10-11-2007, 03:56 PM
callback from model - by El Forum - 10-11-2007, 04:04 PM
callback from model - by El Forum - 10-11-2007, 04:11 PM
callback from model - by El Forum - 10-11-2007, 04:11 PM
callback from model - by El Forum - 10-11-2007, 04:23 PM
callback from model - by El Forum - 10-11-2007, 04:57 PM
callback from model - by El Forum - 10-11-2007, 05:18 PM
callback from model - by El Forum - 10-11-2007, 05:51 PM
callback from model - by El Forum - 10-11-2007, 08:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB