Skip property on Collection save

I need a property that doesn't save for a Collection. I tried overriding Phalcon\Mvc\Collection::getReservedAttributes() and adding my property, but that doesn't work.

Is there something similar to Phalcon\Mvc\Model::skipAttributes() for Collections?

Thanks.

Phalcon rulez!



3.3k

I hacked it like this. Static props don't save. I'd still like to know if there is a way to have a non-saving class property.

class Customer extends Phalcon\Mvc\Collection {

    // static properties not saved to Collection
    private static $currSubscription = null;

    // load Subscription when initialized
    public function initialize() {

        $this->getSubscription();
    }

    // load the Subscription when subscription id set
    public function setSubscriptionId($subId) {

        $this->subscriptionId = $subId;
        $this->getSubscription();
        return $this;
    }

    // get the Subscription
    public function getSubscription() {

        // only load if Subscription not loaded and subscription id set
        if(!self::$currSubscription && isset($this->subscriptionId) && $this->subscriptionId) {

            // load Subscription by id
            self::$currSubscription = Subscription::findById($this->subscriptionId);
        }
        return self::$currSubscription;
    }
}