Table join confusion...

2009-11-07 Thread jakobjp
I need a little assistance with a join over 3 tables. I have the following Models (User > Profile > Infogroup > Information): - User (hasMany Profile) - Profile (belongsTo User, hasMany Infogroup) - Infogroup (belongsTo Profile, hasMany Information) - Information (belongsTo Infogroup) The relati

Auth component + extra variables

2009-10-15 Thread jakobjp
Hello I have a login procedure that requires more information than just the username and password. Controller: "employees" Action: "login" Databasefields needed for login: email, password, group (because it is possible to have the same email for different groups). Login URL: http://mydomain.co

Re: saveAll() with $fieldList problem

2009-07-13 Thread jakobjp
> Array >                 ( >                     [comment] => Comment 1 >                     [user_id] => 1 >                 ) >             [1] => Array >                 ( >                     [comment] => Comment 2 >                     [user_id] => 2 >                 ) >      

saveAll() with $fieldList problem

2009-07-12 Thread jakobjp
I cannot get the $fieldList to work for Model->saveAll() not matter what I try. How should the $fieldList array be formatted when storing a Model plus associated Models via saveAll()? My example: Form fields: User.first_name User.last_name Address.street Address.city ... The two models User an

AuthComponent: Not logged in VS. Not authorized

2009-07-12 Thread jakobjp
It seems to me, that if you're not logged in OR if you are not authorized for a specific action, you will receive the same message ($this->Auth->authError in the Controller). I would, however, prefer two different messages. I.e. "Please login" if not logged in at all, or "Not authorized" if logge

Re: Aggregating child field

2009-05-25 Thread jakobjp
I suspect this to be a pretty common thing to do, so I hope someone can let me know how ;-) On May 24, 11:22 pm, Teh Treag wrote: > jakobip, > > What do you have $this->Event->recursive set to?  Are the associations > done correctly? > > -teh > > On May 24, 9:12 a

Auth and fieldList

2009-05-25 Thread jakobjp
Im having a problem with the $fieldList parameter for my User model's save() method: (in users_controller) $this->data['User']['password_confirm_hashed'] = $this->Auth->password ($this->data['User']['confirm_password']); $fieldList = array( 'first_name', 'last_name', 'email', 'password',

Re: Objects vs. arrays

2009-05-24 Thread jakobjp
lor = $this->data['Apple']['color']; >   } >   return $colour == 'red'; > > } > > -Mark > > On May 23, 9:59 am, jakobjp wrote: > > > > > I've read a few discussions about CakePHP returning objects vs. > > arrays, a

Re: Aggregating child field

2009-05-24 Thread jakobjp
Hmm, I'm not sure I follow the example. At least it didn't help we to resolve this - probably because of lacking skills on my part :-( When I add the following afterFind() function to my Event method... function afterFind($events) { foreach ($events AS $event) { pr($event); } } ... I wo

Aggregating child field

2009-05-24 Thread jakobjp
I have a model Event that hasMany Ticket. Ticket has a field called "price". I would like to accomplish that Event gets an attribute "total_ticket_price", which is the sum of "price" for all of Event's Tickets. I have been trying to looking into the afterFind() method, but I have been unable to

Objects vs. arrays

2009-05-23 Thread jakobjp
I've read a few discussions about CakePHP returning objects vs. arrays, and this is NOT intended to be such. I just have a question, related to it: I used to have (i.e. "before CakePHP") objects like this: class Apple { var $color; var $sweet; function __construct($id = false) { if ($i

Re: Map model attributes to different database fields

2009-04-20 Thread jakobjp
3 pm, brian wrote: > I suppose the burning question is, why do you want both versions of > the app using the same DB? That seems fraught with peril. > > > > On Mon, Apr 20, 2009 at 11:03 AM, jakobjp wrote: > > > I am trying to map model attributes to database fields

Re: Map model attributes to different database fields

2009-04-20 Thread jakobjp
Another way of describing the problem is that instead of having the following query style: SELECT uid, firstname FROM users; I want this query style: SELECT uid AS id, firstname AS first_name FROM users; So that I can use the attributes "id" and "first_name" in the code, but it will work with th

Map model attributes to different database fields

2009-04-20 Thread jakobjp
I am trying to map model attributes to database fields with different names. Example of regular CakePHP model: User Model with attributes "id" and "firstname" would load the appropriate values from same-named database fields "id" and "firstname". Example of my CakePHP mode: User Model with aatri

List with aggregated fields

2009-03-14 Thread jakobjp
I have a list of articles. One of the columns shows an aggregate field, which is the average rating of the article. Problem: The list only shows articles that have at least one rating. The SQL query generated by CakePHP is not considering articles that have no rating at all. The function in the

Advanced relationships (roles on an element basis)

2009-03-10 Thread jakobjp
I'm trying to figure out how to create a system that can handle the following: Models: user, post, category Roles: regular, moderator, admin - User ("regular user") can create posts in categories. - User ("regular user") can edit own posts. - Multiple users can have the role "moderator" in mult

Re: l10n in cakephp > can't get app to switch language

2009-03-10 Thread jakobjp
This is weird: I can successfully change the language with $this- >Session->write('Config.language', 'fr'); in the beforeRender() function in apps_controller.php Why does it not work in beforeFilter()? Does it matter where it's being done? On Mar 10, 2:09 pm,

Re: l10n in cakephp > can't get app to switch language

2009-03-10 Thread jakobjp
On Mar 10, 2:25 am, "jitka (poLK)" wrote: > > I have created two test languages in: > > /app/locale/eng/LC_MESSAGES/default.php > > /app/locale/fre/LC_MESSAGES/default.php > > php extension is reason. CakePHP assumes there plaintext .po (or > preferrable binary .mo) files. Yeah that was a mist

Re: l10n in cakephp > can't get app to switch language

2009-03-10 Thread jakobjp
Unfortunately that didn't do the trick... :-( On Mar 10, 1:42 am, Miles J wrote: > I use app import and it worked for me: > > App::import('Core', 'l10n'); > $l10n = new L10n(); > $l10n->get($locale); > > I also place it in my app controller beforeFilter(). If you are doing > it in another contro

l10n in cakephp > can't get app to switch language

2009-03-09 Thread jakobjp
've been reading a lot about l10n in cakephp now, but there seems to be some confusion about what is the correct way to use languages... I have created two test languages in: /app/locale/eng/LC_MESSAGES/default.php /app/locale/fre/LC_MESSAGES/default.php I am displaying my test string in a view