Closed binarygamura closed 7 years ago
Okay, i think i misread the documents. there is actually no need to create variables in my model classes. i can access all variables loaded from the database from within functions of my model with code like this:
$this->bean->somevalue;
I just had the old Bean pattern i used with hibernate in mind. Well, sorry for opening this issue. And thanks for providing such a nice lib.
Hi,
I am trying to do some OOP with PHP and RedBeanPHP. I created a database "user" and a simple class "User" which extends Redbeans SimpleModel. The class User has one function "getUsername" which accesses a private field "username". The database "user" has a field "username".
When I load an instance from the database via R::find() i can access the field "username" simply for example by $user['username'] but i am not able to access it by calling the function "$user->getUsername()". As far as i understand the documentation, this works as intended and i need to box the value . Here some debug info about a loaded user istance. As you can see, the properties from the database are not copied from the bean to the model instance.
When i do something like $user->getUsername() or $user->box()->getUsername() can not access the value loaded from the database. What am I doing wrong or is it not possible to create model classes with RedBeanPHP which can have function to access member variables? I have a background of using Hibernate for Java for quite some time and im am looking for a way to load entities (not arrays) from a database to get rid of writing CRUD operations by myself.
Thanks in advance
Binary