Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a particular row using id in redbean php

Tags:

php

mysql

redbean

I have database with table "users"

+------+--------------+----------+
|  id  |  username    | password | 
|  22  |  foo         |    foo   |
|  23  |  bar         |    bar   | 
|  24  |  world       |  world   |

I wanna update the username where id = 24

How can i do this using redbean without sequel queries


1 Answers

First, R::load the row into a bean:

$user = R::load('users', 24);

Then update your data:

$user->username = "Bojangles";

And finally save the user back to the table:

R::store($user);

Please be sure to read the manual in the future - an example of how to do this is on the homepage

like image 63
Bojangles Avatar answered Oct 23 '25 06:10

Bojangles