Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Changing the used table for the model on the fly
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
larslinnet@gmail.com  
View profile   Translate to Translated (View Original)
 More options 28 Aug 2007, 12:58
From: "larslin...@gmail.com" <larslin...@gmail.com>
Date: Tue, 28 Aug 2007 11:58:46 -0000
Local: Tues 28 Aug 2007 12:58
Subject: Changing the used table for the model on the fly
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
porksmash  
View profile   Translate to Translated (View Original)
 More options 28 Aug 2007, 18:57
From: porksmash <Petar...@gmail.com>
Date: Tue, 28 Aug 2007 10:57:26 -0700
Local: Tues 28 Aug 2007 18:57
Subject: Re: Changing the used table for the model on the fly
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, "larslin...@gmail.com" <larslin...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
larslinnet@gmail.com  
View profile   Translate to Translated (View Original)
 More options 29 Aug 2007, 09:24
From: "larslin...@gmail.com" <larslin...@gmail.com>
Date: Wed, 29 Aug 2007 08:24:01 -0000
Local: Wed 29 Aug 2007 09:24
Subject: Re: Changing the used table for the model on the fly
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 <Petar...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google