Are you referring to where the files go?

You can do anything in Cake that PHP allows, so extend as many times
as you please.

On Dec 5, 11:54 am, RhythmicDevil <rhythmicde...@gmail.com> wrote:
> Hi Miles,
> thanks for the response. Yeah I think that would be the number 3
> option I Iisted.
>
> The thing is how would I do the following:
>
> AppModel
>     DbBaseModel
>          SomeModel
>     ApiBaseModel
>          AnotheModel
>
> To the best of my knowledge you can actually build that kind of
> heirarchy in Cake right?
>
> On Dec 5, 2:49 pm, Miles J <mileswjohn...@gmail.com> wrote:
>
>
>
>
>
>
>
> > You could always just create 2 base models?
>
> > class ApiBaseModel extends AppModel {}
> > class DbBaseModel extends AppModel {}
>
> > They both would extend AppModel to gain shared functionality and then
> > both would have their own functionality. Cake IS PHP, so you can do
> > whatever you want with classes.
>
> > class User extends DbBaseModel {}
> > class News extends ApiBaseModel {}
>
> > -Miles
>
> > On Dec 5, 11:29 am, RhythmicDevil <rhythmicde...@gmail.com> wrote:
>
> > > My application has two datasources. I use one to talk to MySQL for
> > > ACL. The other is a custom datasource that talks an API my company is
> > > developing. There are about 15 models that use the custom datasource
> > > and will probably be more. For each of those models I need to share
> > > methods and  properties but DO NOT want the ACL models to have them so
> > > they cannot go into AppModel.
>
> > > The reason I have many models for the API is that I want the data
> > > structures returned by the Model to have the correct naming. I suppose
> > > I could set the name on the fly but for now I am curious how to solve
> > > this other problem.
>
> > > Do behaviors solve this problem? I did not think that was really their
> > > function. These are the properties and methods I need shared and it
> > > has to do with how the datasource works.
>
> > >     public $useDbConfig = 'gti';
> > >     public $useTable = false;
>
> > >     public function __construct()
> > >     {
> > >         parent::__construct();
> > >     }
>
> > >     /**
> > >      * Overridden paginate method - group by week, away_team_id and
> > > home_team_id
> > >      */
> > >     function paginate($conditions, $fields, $order, $limit, $page = 1,
> > > $recursive = null, $extra = array())
> > >     {
> > >         //var_dump($conditions, $fields, $order, $limit, $page,
> > > $recursive, $extra);
> > >         $recursive = -1;
> > >         //$group = $fields = array('week', 'away_team_id',
> > > 'home_team_id');
> > >         return $this->find('all', compact('conditions', 'fields',
> > > 'order', 'limit', 'page', 'recursive'));
> > >     }
>
> > >     /**
> > >      * Overridden paginateCount method
> > >      */
> > >     function paginateCount($conditions = null, $recursive = 0, $extra
> > > = array())
> > >     {
> > >         //var_dump($conditions, $recursive, $extra);
> > >         return 1000;
> > >         $sql = "SELECT DISTINCT ON(week, home_team_id, away_team_id)
> > > week, home_team_id, away_team_id FROM games";
> > >         $this->recursive = $recursive;
> > >         $results = $this->query($sql);
> > >         return count($results);
> > >     }
>
> > > I see the following options:
>
> > > 1. Place the code in the AppModel file and then do some work every
> > > time those methods and properties are needed to decide whether I use
> > > these or the other. That seems like a lot of work.
>
> > > 2. Duplicate the code in each model
>
> > > 3. Use one model for the API and then just set it's name so that my
> > > data structures are named correctly.
>
> > > And again, behavior? Probably not, but figured I'd ask one more time.
>
> > > Thanks for any advice.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to