Hello!

On Jul 1, 10:02 am, "b logica" <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 1, 2008 at 11:59 AM, geste <[EMAIL PROTECTED]> wrote:
>
> > For several new CakePHP applications (I'll call them app1, app2,
> > app3), I will need to implement a number of drop-down menus.  These
> > would be things like building codes that are already stored in a
> > separate database (I'll call that the "lookup" database).
>
> I think it's best to just repeat the data for each app. Unless you're
> talking about millions of records, or if the lookup data is subject to
> change, I don't think there's any big deal with sharing the info. My
> use of this sort of thing usually involves a list of countries,
> provinces, or similar. I just keep these things handy in their own SQL
> file--one for Postgres and one for MySQL--and add them to my app as
> needed.

States and countries are the classical example, but in this case the
data are longer and will change over time -- inventory of space/rooms,
coordinates, et cetera.  Not millions of records, but not the short,
static list of states that are the most typical case.  So I will still
look for a way to not duplicate them (I am just starting now to add
secondary DB to my database.php and I'll see how that goes.  I'm a
little concerned about switching connections between DBs just to do
simple things like display labels and drop-downs; not sure if using
persistent connections would help make that work....)

>
> > So, what I would like to do is have app1, app2 and app3 (each with
> > their own database) use a shared set of functions that use lists/
> > values pulled from the lookup database.
>
> What sort of functions? Do you need to filter the data? Or are you
> simply pulling it from the DB to create a select list?

A number of these could be filtered lists.  Like "show me only the
rooms/spaces that are associated with budget X or with building Y".

>
> > In the CakePHP 1.2 world is there an accepted or recommended way to do/
> > organize this?  As a component?  A plug-in?  I see a lot of examples
> > of building menus/lists associated with each individual model, but not
> > many examples that implement as a separate library using a different
> > database as source of the model.
>
> You probably want a behavior.

I will go off and look at behaviors!

>
> > Another use of this central "library" would be to provide functions/
> > methods that display "friendly" values -- show building_name instead
> > of building_id or show last_name+first_name instead of person_id.
>
> You can set the displayField property before doing a find('list',
> ...). Also, have a look at the AutoField behavior:

Great.  That helps.  I have done a fair amount of typical, ugly, non-
MVC PHP for small apps, but I am just starting to find my way around
CakePHP concepts and methods.

Thanks!

Jim


>
> http://cakeexplorer.wordpress.com/category/model/
>
> > What I'd like to avoid is littering a bunch of these functions in each
> > application.
>
> > Any thoughts appreciated!
>
> > Jim

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to