0

i want to know how create a query such as this in redbeanphp:

select concat(first_name,' ',last_name) AS fullname from person;

i know redbean has a bindFunc Method but i do not know how to do this and this topic was not cover in redbean Documentation .

Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65

1 Answers1

0

I would not use the bindFunc functions, they are not meant for these kind of things. I recommend to use a FUSE model.

Just add a class named Model_Person (extends SimpleModel) docs: http://www.redbeanphp.com/models Now add a method called getDisplayName() or something, inside this method you do something like:

public function getDisplayName() { return $this->bean->firstName . ' ' . $this->bean->lastName; }

Now you can do this:

$person = R::load('person', $id); echo $person->getDisplayName();

and it will show the full name...

Hope this helps, cheers Gabor

Gabor de Mooij
  • 2,997
  • 17
  • 22