Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Inserting data using ORM
  • I have the following code.

    // Will execute INSERT INTO `users`(`name`,`email`,`password`)
    // VALUES ("John Random", "john@example.com", "s0_s3cr3t")
    list($insert_id, $rows_affected) = DB::insert('users')->set(array(
    'name' => 'John Random',
    'email' => 'john@example.com',
    'password' => 's0_s3cr3t',
    ))->execute('second_db');

    I found this from http://fuelphp.com/docs/classes/database/usage.html

    Well this is query, but how can I convert this to ORM. Like my following insert code. 

    $user = Model_User::find("first", [ "where" => [ ["email", $email] ] ]);

    $user->name = Session::get_flash("name "); $user->email= Session::get_flash("email"); $user->password= Session::get_flash("password");
    $user->save();



  • Yup, that would be right.

    Although if you use the Auth package, you should really use it's update method for updating users, it has security checks measures against hacking built-in.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion