how to tell if an attribute exists

flag Questions

Hi,

I'm using $attribValue = $this->readAttribute(AppModel::FIELD); to get the value of this model/attribute.

If the field not exists, I have value is $attribValue = null, but the field, if exists, can contain null values too.

so ... how do I know if the field/attribute exists and what its value?

sorry for my english

solved
Jul 3/15 at 02:20 2 Answers 22 Views -1

About the Author

I'm creating a website that provides a service to people that allows them to access their documents and desktops remotely, and obviously, they should be the only ones that can access their information, but how do I go about doing that?

Answers ( 2 )

    0
    Jul 7/15 at 04:03

    Just to mention it: both method_exists() and is_callable() return true for inherited methods:

    0
    Jul 3/15 at 02:20

    You can try override readAttribute($attribute) function in your model

    For example:

    public function readAttribute($attribute)
    {
        if(!isset($this->{$attribute})) {
            return false; // or throw new \Exception("lore ipsum");
        }
        return parent::readAttribute($attribute);
    }

Leave a reply

 Prev question

Next question