Friday, December 5, 2008

Re: Custom queries/sql in models/behaviors

> I am not a big fan of the model system because its very limiting if you have advanced queries.

How did you come to that conclusion?

...

If you properly created your models and associations, a simple find
('all') will give you: Team, Roster, Game and League models with all
the relevant info.


On Dec 4, 6:23 pm, gearvOsh <mileswjohn...@gmail.com> wrote:
> Ok in my current system (its a gaming league) I have packages. I will
> 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: