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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment