use a Team package as an example. In this Team package I have a method
getTeamInfo() which calls out to external queries. I do this so I only
have to write a query once and can access its results through a method
call. I prefer this way instead of having to write the same query over
and over for different instances.
require('teamExt.php');
require('userExt.php');
class Team {
public static function getTeamInfo($team_id) {
$team = TeamExt::getTeamInfo($team_id);
if (!empty($team)) {
$team['roster'] = TeamExt::getRoster($team_id);
$team['games'] = TeamExt::getGamesPlayed($team_id);
$team['stats'] = TeamExt::getStats($team_id);
$team['leader'] = UserExt::getUser($team['leader_id']);
}
return $team;
}
}
Now when I call Team::getTeamInfo I should have its team info, roster,
games played, the team leader and league statistics. Now the problem
with CakePHP is its model system. I am not a big fan of the model
system because its very limiting if you have advanced queries. I was
thinking of doing it this way:
Class Team = Model Team
TeamExt = Team Behavior
UserExt = User Behavior
$team = $this->Team->getTeamInfo();
But how would I do custom queries in a behavior? And the logic for
behavior is wrong with my idea anyways. Anyone have an idea of how I
can accomplish my setup in CakePHP, because this is the one thing
stopping me from using CakePHP. And no I will not use joins.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment