Welcome Guest, Not a member yet? Register   Sign In
changing object in loop in Datamapper ORM to save
#7

[eluser]mak.gnu[/eluser]
When I run the following code it gives error stating
Code:
The id field must contain an integer.
Code:
$t = new Truck();
        foreach ($t->fields as $k => $val){
            $t->$val = $this->input->post("$val");
        }
        if (!$t->save()) {
            // or we can loop through the error's all list
            foreach ($t->error->all as $error) {
                echo $error;
            }
        }

And whenI run following code it works like a charm. and saves the data.

Code:
$t = new Truck();
        foreach ($_POST as $k => $val){
            $t->$k = $this->input->post($k);
        }
        if (!$t->save()) {
            // or we can loop through the error's all list
            foreach ($t->error->all as $error) {
                echo $error;
            }
        }

What is wrong in using $t->fields


Messages In This Thread
changing object in loop in Datamapper ORM to save - by El Forum - 05-11-2011, 12:20 PM
changing object in loop in Datamapper ORM to save - by El Forum - 05-12-2011, 05:43 AM
changing object in loop in Datamapper ORM to save - by El Forum - 05-13-2011, 02:30 AM
changing object in loop in Datamapper ORM to save - by El Forum - 05-13-2011, 02:36 AM
changing object in loop in Datamapper ORM to save - by El Forum - 05-13-2011, 05:00 AM
changing object in loop in Datamapper ORM to save - by El Forum - 05-13-2011, 06:37 AM
changing object in loop in Datamapper ORM to save - by El Forum - 05-13-2011, 08:46 AM
changing object in loop in Datamapper ORM to save - by El Forum - 05-13-2011, 08:57 AM
changing object in loop in Datamapper ORM to save - by El Forum - 05-13-2011, 09:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB