On Sep 5, 5:17 pm, AD7six <[EMAIL PROTECTED]> wrote:
> 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?
>
It's not so much a security thing as it is a confusion thing. Cake
really should have a read only model structure. Why give the developer
the gun if all he can do is aim it at his head? The argument you're
giving me reminds me of arguments people have given me against public/
private/protected name spaces - some people think they aren't worth
anything. It's not SECURITY, but it does prevent mistakes and it does
implicitly provide clarity on how something should be used.
> > 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.
>
You're taking the comment ouf of context a bit. I don't want a
component/helper/behavior to create a read only model. That is clearly
the wrong implementation. I want something to act as a single object
that I can call upon to get the information I need out of this
grouping of tables. I want it to be something more specialized than a
general model. I want to be able to instantiate some sort of Geo
object and ask it questions such as what cities are in this zip code
or what is the distance between these two zip codes. I don't want to
have to manage multiple models for one main task - geography. This
normalized table structure does not lend itself too nicely to Cake's
conventions for ORM and really doesn't need all the overhead the ORM
implementation has if I really only need to read from it.
> > 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).
>
I realize that, but this is confusing. I now have 4 models to choose
from in order to provide the functionality I need instead of one
compact object that does everything Geo-related. Unlike typical Cake
implementations where the complex ORM makes sense, in this case it
makes no sense. The rest of my project fits perfectly within the Cake
conventions, however.
> > 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 HOPE I have something setup wrong, but it just doesn't seem to play
well with this setup.
Cake 1.2 (latest build)
1 controller
ZipCodeController - scaffolding turned on, $uses ZipCode
4 models
ZipCode (HABTM City)
City (HABTM ZipCode, BelongsTo State)
State (HasMany City, BelongsTo Country)
Country (HasMany State)
That's it. If I navigate to /ZipCode Apache explodes. Any
suggestions?
> > 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).
>
$uses is a controller property, not a model property. $useTable is the
model property, and it is a string not an array. It's meant to allow
the use of a table that doesn't follow cake naming conventions, not
for allowing a model to talk to more than one table at once.
> > 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
Once again, I agree that when it comes down to actual security the
database is the place. But just to reiterate, it's for clarification
from a code cleanliness standpoint - much like properly using private/
public/protected namespaces - that is my intention here. Also, the
intention of having it be compact.
Maybe there is simply no good answer. I only raise the question.
Creating a component is the best option I've heard so far, so I will
work on that tonight and see what comes out of it.
Thanks again!
- Jason
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---