Re: Conditionally set defaultConnectionName

2014-11-03 Thread Joe Theuerkauf
Heh, just for the record, the arguments were reversed: ConnectionManager::alias('admin', 'default'); ($from, $to) i'm sure you were just making sure i'm paying attention. ;-) It's working. Very grateful for the help. -joe On Monday, 3 November 2014 04:02:00 UTC-5, José Lorenzo wrote: > > In you

Re: Conditionally set defaultConnectionName

2014-11-03 Thread José Lorenzo
In your controller under the admin namespace do: public function beforeFilter() { parent::beforeFilter(); \Cake\Datasource\ConnectionManager::alias('default', 'admin'); } On Sunday, November 2, 2014 4:44:16 PM UTC+1, Joe Theuerkauf wrote: > > Sorry, what i meant was, i don't plan to use defau

Re: Conditionally set defaultConnectionName

2014-11-02 Thread Joe Theuerkauf
Sorry, what i meant was, i don't plan to use defaultConnectionName the same WAY i was using it for the Captcha question. If it's a legit option, i'll use it, but i see your point about not using defaultConnectionName AND a connection alias. On Sunday, 2 November 2014 10:40:20 UTC-5, Joe Theuerk

Re: Conditionally set defaultConnectionName

2014-11-02 Thread Joe Theuerkauf
Thanks for that tip, Mark. i don't plan to use defaultConnectionName in this scenario (as i did for the Captcha thread where the table i needed is in a different database). i can see where aliasing the connection will make it hard to access the original connection. Which is why i asked for som

Re: Conditionally set defaultConnectionName

2014-11-02 Thread mark_story
If you alias connections you don't need to use defaultConnectionName(). Aliasing the connection makes it much harder to access the regular default connection as whenever you ask for it you get the admin connection instead. -mark -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us o

Re: Conditionally set defaultConnectionName

2014-11-01 Thread Joe Theuerkauf
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 conn

Re: Conditionally set defaultConnectionName

2014-10-31 Thread José Lorenzo
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: > >

Re: Conditionally set defaultConnectionName

2014-10-30 Thread Joe Theuerkauf
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 grante

Re: Conditionally set defaultConnectionName

2014-10-30 Thread José Lorenzo
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

Conditionally set defaultConnectionName

2014-10-29 Thread Joe Theuerkauf
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