Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Inserting data using ORM
vandolph
October 2015
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();
Harro
October 2015
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.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
October 2015