Re: Four sites using same database, but only their own records
Or you could use a beforeFind() to add the condition. I used that on a project that dealt with multiple finanical years. I changed the beforeFind() to alter the conditions to include the restriction of a specific year. in your case something like this in AppModel (having defined ARTIST_ID in bootstrap as suggested above). function beforeFind($q){ $q['conditions'][$this-name'.artist_id'] = ARTIST_ID; return $q; } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Four sites using same database, but only their own records
http://bin.cakephp.org/view/1178242700 This is the behaviour I use for this purpose. Basically it looks at every query, and if you haven't already set any conditions that look at the owner id (or artist_id in your case), then it automatically appends a condition to only retrieve those owned by the model's $active_owner_id property, or what is in the session. Using the session in a behaviour like this is a terrible hack - but it works for us. If you don't need to do this, remove that stuff and just always have $this-Track-active_owner_id = 123; $tracks = $this-Track-findAll(); On Apr 22, 7:44 am, tgies [EMAIL PROTECTED] wrote: I am setting up a website for an independent music publisher. Rather, I am setting up three websites: the label's own website and three artists' websites. We will call the artists foo, bar, and plugh. All of these sites use the same database. The rationale behind this is that each artist's catalog can be populated with their songs/albums from the label's central catalog, with the label's catalog displaying all songs/albums from all artists. All models are associated with a certain artist_id, which should make it possible for each artist's site to transparently only select its own database records. But how would I go about doing this? Is there something I can add to AppModel to automatically add this constraint to every find? Thanks, tgies --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Four sites using same database, but only their own records
On Apr 22, 3:20 am, ModByChris [EMAIL PROTECTED] wrote: Or you could use a beforeFind() to add the condition. I used that on a project that dealt with multiple finanical years. I changed the beforeFind() to alter the conditions to include the restriction of a specific year. in your case something like this in AppModel (having defined ARTIST_ID in bootstrap as suggested above). function beforeFind($q){ $q['conditions'][$this-name'.artist_id'] = ARTIST_ID; return $q; } This is exactly what I'm looking for. One thing, though: Is there a way to make this sort of constraint work through associations? Like say Artist has many Track has many File (for various downloadable formats of each freely-downloadable track), and File does not have artist_id, but Track does. How do I either make this condition work through associations like that or, if nothing else, make it so it doesn't try to apply the condition to models not directly having an artist_id? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Four sites using same database, but only their own records
I am setting up a website for an independent music publisher. Rather, I am setting up three websites: the label's own website and three artists' websites. We will call the artists foo, bar, and plugh. All of these sites use the same database. The rationale behind this is that each artist's catalog can be populated with their songs/albums from the label's central catalog, with the label's catalog displaying all songs/albums from all artists. All models are associated with a certain artist_id, which should make it possible for each artist's site to transparently only select its own database records. But how would I go about doing this? Is there something I can add to AppModel to automatically add this constraint to every find? Thanks, tgies --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Four sites using same database, but only their own records
Funny, I just started re-doing a site for an independent label, also. While I'm not creating separate sites for each artist, I've decided to do pretty much all of the SELECTs based on the artists' slugs. So, instead of doing a read(null, $id) I need to do a findBySlug($slug) and adjust the routes accordingly. If you're creating entirely separate Cake sites for each artist, you could define('ARTIST_SLUG', 'whatever') in each bootstrap.php. Once you've done your basic selection based on the slug you should be able to leave your recursive associations based on the id, as normal. On Mon, Apr 21, 2008 at 5:44 PM, tgies [EMAIL PROTECTED] wrote: I am setting up a website for an independent music publisher. Rather, I am setting up three websites: the label's own website and three artists' websites. We will call the artists foo, bar, and plugh. All of these sites use the same database. The rationale behind this is that each artist's catalog can be populated with their songs/albums from the label's central catalog, with the label's catalog displaying all songs/albums from all artists. All models are associated with a certain artist_id, which should make it possible for each artist's site to transparently only select its own database records. But how would I go about doing this? Is there something I can add to AppModel to automatically add this constraint to every find? Thanks, tgies --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---