Thanks for the idea José. Could you elaborate a little on usage? The API 
explains how it works, but i'm fuzzy on *where* to use it. Doesn't looks 
like it's mentioned in the Cookbook.

As a basic example, if i have these controllers:

*/App/Controller/AboutController*
- public Controller that connects to table "Parks" to produce info about 
the company's parks (locations, park maps, owner-entered blah-blah, etc.)
- Should only use the restricted *actual *"default" connection

*/App/Controller/Admin/AboutController*
- Admin-access controller where the "Parks" records are managed
- Needs the elevated "admin" connection for data changes.

i presume i would use the *alias* method somewhere in the Admin's 
AboutController (or a step up in the AdminController abstract the admin 
controllers inherit from), but how & where?

Thanks for your help.
-joe


On Friday, 31 October 2014 04:51:29 UTC-4, José Lorenzo wrote:
>
> The easiest way is to alias the connection:
>
> \Cake\Datasource\ConnectionManager::alias('default', 'admin');
>
> What it does is that, when a table is created instead of passing the 
> default connection it will pass the admin one.
>
> On Friday, October 31, 2014 1:42:42 AM UTC+1, Joe Theuerkauf wrote:
>>
>> Correct. When the Admin is logged in to that part of the site, the 
>> connection with the elevated account would be used for all requests so data 
>> edits can be performed. For the general user, the restricted connection 
>> would be used, where data edits aren't permitted (with limited exceptions 
>> granted to that db account). i don't want to mix data connections on a 
>> single request.
>>
>> Thanks.
>> -joe
>>
>>
>> On Thursday, 30 October 2014 04:10:35 UTC-4, José Lorenzo wrote:
>>>
>>> Let me see if I understood correctly: For certain admin actions you want 
>>> to use the admin connection instead of default for ALL tables used in that 
>>> request?
>>>
>>> On Thursday, October 30, 2014 4:25:30 AM UTC+1, Joe Theuerkauf wrote:
>>>>
>>>> i may be overthinking this - if so, tell me.
>>>>
>>>> i'd like to have a DB config for the general website user, who needs 
>>>> only SELECT for most things, and a separate config for the Admin side of 
>>>> the site where other privileges are needed.
>>>>
>>>> Since *defaultConnectionName* returns which config to use, is it 
>>>> possible to determine within that method which connection i need to return 
>>>> (Admin or basic) for the Table?
>>>>
>>>> My original thought was to somehow set the connection i need in the 
>>>> controllers, as i have an abstract AdminController that the Admin-level 
>>>> controllers inherit from. But i don't see any obvious reference to doing 
>>>> this in the documentation. So i thought a conditional return from 
>>>> *[Table]::defaultConnectionName* might work.
>>>>
>>>> If it's better just to use a single higher-privilege account for all 
>>>> purposes, so be it. Just thought i'd ask. :)
>>>>
>>>> Thanks.
>>>> -joe t.
>>>>
>>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to