Is it possible to use PHP's property_exists() on a bean?

36 views
Skip to first unread message

Coho

unread,
Jan 25, 2016, 8:35:31 PM1/25/16
to redbeanphp
I need to test whether a property is set on a bean inside the model. None of these variations worked:

property_exists($this, 'status');
property_exists($this->bean, 'status');

status is a property that has been dynamically added:

    $band = R::dispense( 'band' );
    $band->status = 'inactive';
    R::store( $band );

Here is the model:

    class Band extends \RedBeanPHP\SimpleModel {
        public function update() {
            var_dump(property_exists($this, 'status'));    // returns false
            var_dump(property_exists($this->bean, 'status'));   // returns false
        }
     }

Thanks for any tips.


Coho

unread,
Jan 25, 2016, 8:40:35 PM1/25/16
to redbeanphp
Forgot to mention that I can't use isset() since I want to detect situations in which $band->status = null

gabor

unread,
Jan 26, 2016, 3:34:20 PM1/26/16
to redbeanphp
have you tried isset? beans implement the array inteface.
Reply all
Reply to author
Forward
0 new messages