On Sep 4, 5:32 pm, Jason <[EMAIL PROTECTED]> wrote:
<snip>
>
> I would like to be able to access this data through one object that is
> locked down. There will be no reason for my application to ever add or
> delete from these tables.

You cannot do anything within Cake to prevent the code $this->Model-
>query("Update other_table SET x = y") from working, or if someone
wanted to really cheat from using native PHP db functions.

Why don't you just remove privileges for the application's database
user to update or delete from (or truncate) these tables once set up?

> I was hoping that I could create something
> sort of like a Component is to a controller or a helper is to a view
> for a model. Nothing like this seems to exist, however.

Behaviors ;) you could create one with beforeDelete and beforeSave
returning false. But this is the wrong place for such logic imo.

> If I were to use Cake's built in ORM, it would be as follows:
>
> zip_code has and belongs to many city
> city has and belongs to many zip_code, city belongs to state
> state has many city, state belongs to country
> country has many state
>
> Using it this way, which model would I then use? How do I keep coders
> from using these models to edit the tables?

The model methods acts upon it's own table only with a few notable
exceptions (cascading deletes but most importantly query() can be used
for anything).

> Isn't this a LOT of
> queries everytime I instantiate one of these models? And scaffolding
> totally blows up (spikes my Apache process to 100% and doesn't let go)
> when I attempt to use this type of ORM.

Then something isn't set up correctly.

> I need a way to have an object talk to these tables and provide me
> with the few functions I need (distance between two zip codes, radius
> searching, etc.) without providing full ORM. I also need to be able to
> access this object from within any controller and it needs to use the
> DB connection that Cake sets up.

That's explained in the manual (var $uses in the model chapter).

> What is the best way to accomplish this while staying within the
> constraints and guidelines of the Cake system?

By following conventions and putting your "you can't touch these
tables" logic in the right place: the database.

hth,

AD


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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