String vs Bean

16 views
Skip to first unread message

clydach

unread,
Jan 10, 2017, 2:54:07 PM1/10/17
to redbeanphp
I'm a new user of RB and i am quite impressed.

My first efforts brought up a nagging little question.
I found I was using both functions  R:load( 'bean_type', $id ) and R:store( $bean )
Why the asymmetry in the first arguments??

I am extending R to provide a store() function (and others) that can take either a string or a bean.
class RB extends R {
static function load($bean, $id) {
 
if (is_string($bean) return parent::load( $bean, $id );
  $properties
= $bean->getPropertiesAndType();
 
return parent::load( $properties[1], $id );
 
}    


Am I courting disaster?
If not, why is this capability not already built in? It would be more consistent if functions like load and store
(and find, etc)  had similar signatures.

 

gabor

unread,
Jan 11, 2017, 5:18:06 AM1/11/17
to redbeanphp


I find this hard to say, I think not.
However I find this very strange.

I created the facade for people to 'have an easy way' to use RedBeanPHP.
It's not proper OOP I know that.

The strange thing is, there is a proper OO way to use RedBeanPHP, but it seems to be neglected: http://www.redbeanphp.com/index.php?p=/non_static
So why try to make the facade more object oriented instead of just using the instances behind the facade in the first place?

There seems to be a nuance here I dont really understand.
Anyway good luck.

cheers
Gabor
Reply all
Reply to author
Forward
0 new messages