I haven't tried this; but try it and see what happens.

1- Create app/models/app_model.php
2- In there you can have

 class AppModel extends Model {
        
        protected $sYourPropery = 'property';

 } // End of AppModel{}

All models that extend AppModel should now have access to
$sYourProperty. In one of your models for example try the following:

public function testing() {
   return $this->sYourProperty;
} // End of testing()

and call it from the controller.

Hope that helps.

Regards,

Alfredo
$this->Model->
On Mon, Mar 16, 2009 at 2:01 PM, yaman666 <[email protected]> wrote:
>
> Most of my models have an additional property that I was trying to
> preload by overloading AppModel constructor.
>
> class AppModel extends Model
>        public function __construct() {
>                parent::__construct();
>                // Load custom property from database and unserialize
> value
>        }
>        public function beforeSave() {
>                // Serialize and save custom property to database
>        }
> }
>
> That broke cakephp when using hasAndBelongsToMany. I filed a bug
> report (https://trac.cakephp.org/ticket/6194) but was told that I
> shouldn't be overloading AppModel.
>
> Can anyone suggest another simple way to accomplish what I want
> without having to write each time $model->initialize(); to preload the
> custom property for all the models?
>
> Thanks!
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to