I'm using amazing orm "RedbeanPhp" from http://redbeanphp.com/, I like how it speeds up the development so much, but the documentation is a bit outdated.
R::findAll()
?For example I only want to select id, email from users, this will grap all the users columns, but I only need 2 columns.
To solve this I currently use a bit verbose code:
$users = R::findAll('users')->export();
foreach($users as $user){
unset($user->password, $user->token);//...etc
}
print_r($users);
But it would be nice if could set this inside a fuse model or something?!
You can use getAll($sql_query)
instead findAll()
...in your example
$users= R::getAll('select id,email from users')'
More info about querying with RedBeanPHP here
Only "con": $users
is not an array of beans, just an array of associative array, having colnames as indexes.
If not enough for you, you can use function convertToBeans(...)
as detailed in the link included before