Re: "direct" data access?

2007-01-03 Thread Veloz


Thanks for all the replies.

It seems like Cake's ActiveRecord implementation is great for what I'd
consider straight forward "CRUD" activities, but we have a couple
scnearios that don't seem to fit so well, in a currently existing app I
am thinking about porting to Cake:

1) The table name is not known in advance, effectively the application
code "tells" the data layer the desired table name to use. I'm not sure
if Cake's "$useTable" can be set "on the fly" or if it has to be part
of the class "static" definition.  I'm assuming it has to be defined in
advance, which would be a problem in this case

2) Creation of temporary tables - this seems to be a bit of a chicken
and egg problem: If I don't yet have a table, I can't have a model
representing that table, wihtout a model, I can't easily execute
database calls (afaik) to create the table.. I could have another model
pointing to some other unrelated pre-existing table, and then invoke a
method on that model to create the temp table but that feels like a bit
of a hack.

3) Some of our tables hold data that is formatted for use by a model
only - for example, the model performs calculations on the data and it
is only the result of these calculations that are useful in the domain.
In these cases, it would be nice to not expose all the other abilities
of ActiveRecord to the outside world for this model. It would be nice
to limit them to just using the API's that we have defined.  This is
kind of similar to the OO problem of composition - when you wrap up an
inner object in an outer object - sometimes you want the outer object
to just use the abilities of the inner object but not to publically
exposes the abilities of the inner object through the outer object

4) We have some current data routines that dynamically build pretty
optimized SQL statements, often involving nested selects and several
layers of joins. My problems with this are: 1) It hurts my brain to try
to figure out how to tell Cake to "do the same thing" through
associations, etc (I'm not every sure associations could cover what I'm
trying to do?) 2) the resulting combined data represents a conceptual
new entity in the domain that does not map to a single table in the
database, thus it feels wierd to arbitrarily pick "one" of those tabes
that the SQL accesses as the table this model represents, i.e., either
by matching the name of the model to this table or by setting it via
$useTable.

In this case I think ideally I'd like the ability to create a Model
named something like "FilteredRespondentGlobalTabulations", not have to
tie it to a particular table (or through assoications to other table),
be able to issue my own SQL through Cake's DboMysql (for example) and
not expose other data access methods through this model such as "save",
etc.

Thoughts?

Since I'm  new to Cake I'm still in that mode where you resist using
the tool for the more complicated tasks because it seems like you are
forcing a round peg in a square hole - probably some  of this will go
away with more experience and input from the group :-)

Thanks, Michael


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: "direct" data access?

2007-01-02 Thread TJSingleton



I think we are going to have some database access needs that may not be
easy to express using Cake's ActiveRecord, so we are trying to figure
out how to still have our models access the database using Cake classes
instead of interjecting our own connection managment code, etc.


What kind of functionality are you looking to do? Could you just create
custom model functions that utilizes the query() and execute() methods?

http://manual.cakephp.org/chapter/models

--
TJ Singleton


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



RE: "direct" data access?

2007-01-02 Thread Mariano Iglesias


I would really challenge the concept of active record not being suited for
some app necessities, but that's a subject for another thread.

You can *still* make your model extend AppModel but use your own fully
featured SQL queries as model functions and still take advantage of CakePHP
database connection methods.

Other low-level option is to just use the classes AppModel uses for database
connectivity (take a look at cake/libs/model/*)

-MI

---

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 


BAKE ON!


-Mensaje original-
De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
de Veloz
Enviado el: Martes, 02 de Enero de 2007 06:23 p.m.
Para: Cake PHP
Asunto: "direct" data access?


I'm pretty new to Cake and have this question: is it possible to use
Cake's lower level database classes in the case that you do not descend
your model from AppModel?

In other words, if you want to create a model class that does not
descend from AppModel, but still needs some database access support,
can you somehow use classes like DataSource and/or DboMysql?

Does anyone know how to go about setting these up?

I think we are going to have some database access needs that may not be
easy to express using Cake's ActiveRecord, so we are trying to figure
out how to still have our models access the database using Cake classes
instead of interjecting our own connection managment code, etc.

TIA!
Michael



__ InformaciĆ³n de NOD32, revisiĆ³n 1953 (20070102) __

Este mensaje ha sido analizado con  NOD32 antivirus system
http://www.nod32.com



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: "direct" data access?

2007-01-02 Thread Chris Hartjes


On 1/2/07, Veloz <[EMAIL PROTECTED]> wrote:


I'm pretty new to Cake and have this question: is it possible to use
Cake's lower level database classes in the case that you do not descend
your model from AppModel?



Models don't have to be database dependent...but you lose the ability
to use all the neat built-in helpers if you don't extend AppModel, and
thereby connect to a database.

I've used Felix G's GoogleAnalytics model for a reporting app at work,
and that is definitely not database related.

If you hunt around on my blog (link is in my signature block) you can
find a link to Felix's posting about it.

Hope that helps.



--
Chris Hartjes

"The greatest inefficiencies come from solving problems you will never have."
-- Rasmus Lerdorf

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: "direct" data access?

2007-01-02 Thread John David Anderson (_psychic_)



On Jan 2, 2007, at 2:22 PM, Veloz wrote:



I'm pretty new to Cake and have this question: is it possible to use
Cake's lower level database classes in the case that you do not  
descend

your model from AppModel?

In other words, if you want to create a model class that does not
descend from AppModel, but still needs some database access support,
can you somehow use classes like DataSource and/or DboMysql?


This sounds like you want a class that doesn't have database access  
but needs database access.


I'd write a model that extends the AppModel, then include your own  
domain specific stuff additionally.



Does anyone know how to go about setting these up?

I think we are going to have some database access needs that may  
not be

easy to express using Cake's ActiveRecord, so we are trying to figure
out how to still have our models access the database using Cake  
classes

instead of interjecting our own connection managment code, etc.


Details? We might be able to better help if we knew why Cake's  
existing setup doesn't work for you.


-- John

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



"direct" data access?

2007-01-02 Thread Veloz


I'm pretty new to Cake and have this question: is it possible to use
Cake's lower level database classes in the case that you do not descend
your model from AppModel?

In other words, if you want to create a model class that does not
descend from AppModel, but still needs some database access support,
can you somehow use classes like DataSource and/or DboMysql?

Does anyone know how to go about setting these up?

I think we are going to have some database access needs that may not be
easy to express using Cake's ActiveRecord, so we are trying to figure
out how to still have our models access the database using Cake classes
instead of interjecting our own connection managment code, etc.

TIA!
Michael


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---