I have been looking into it and have come up with the following
function
function setUseTable($service_id = null) {
if ($service_id) {
// gets the table_prefix and sets it to the useTable variable.
$prefix = $this->query('SELECT table_prefix FROM
service.services
WHERE id = '.$service_id);
$this->useTable = $prefix . '_users';
}
}
But is not quite sure that it is the most efficient way of getting the
table prefix (I'm annoyed i had to write sql directly in my code.), is
there a better way of doing so?
On Aug 28, 7:57 pm, porksmash <[EMAIL PROTECTED]> wrote:
> You can try the $useTable variable in your model. It is described in
> Section 3 of the Models section of the CakePHP
> manual:http://manual.cakephp.org/chapter/models
>
> -Porksmash
>
> On Aug 28, 6:58 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Hey guys,
>
> > I'm new to this list and after continuous searching through its
> > archives and the rest of the web, if I have missed it please direct me
> > to it. But here it goes.
>
> > What I want to do sounds quite simple, or at least to me.
>
> > I have a list of services which is stored in the table "services" for
> > each service there is a user database.
> > In the "services" table there is a field called "table_prefix" which
> > refers to the prefix of the user database that belongs to that given
> > service.
>
> > this gives a structure as the following:
> > services (table that contains all the services)
> > newsletter1_users (contains all users that belongs to the service
> > "newsletter1")
> > newsletter2_users (contains all users that belongs to the service
> > "newsletter2")
>
> > It is required that the user databases are separated this way to keep
> > the system quick and easy to maintain.
>
> > I planned to create a dynamic Model that changes the $useTable based
> > on which service the client uses, but before I dive in to deep with
> > cakePHP I would like to know if this is something that cakePHP even
> > supports.
>
> > If it doesn't could one with a better knowledge, of how cakePHP works,
> > point me to a good place to start modifying it to fit my needs.
>
> > Best Regards
>
> > Lars S. Linnet
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---