Re: associations assoc. array keys too restricted?

2006-05-30 Thread GregL
Sorry for the confusing thread. I think I figured out what the communication gap is. I said "key" meaning PHP associative array key as in "key" => "value", I didn't mean primary DB key. All my primary keys in the DB are called "id" and I've never had trouble with Cake accessing that. I resolved m

Re: associations assoc. array keys too restricted?

2006-05-29 Thread nate
I'm saying you don't have to change your primary key's, you just need to tell Cake what they are; I understand your constraints in trying to integrate with an existing site. Cake tries to be as real-world-friendly as possible. If you post your db schema for the relevant tables, it'd be easier to

Re: associations assoc. array keys too restricted?

2006-05-29 Thread GregL
I am adding Cake to an existing site, so I wasn't easily able to accomodate the naming conventions. I did go through and change all the primary keys to "id", however, so that isn't what's keeping my models from seeing each other. I'm still not fully understanding why, but I'm just going to stick

Re: associations assoc. array keys too restricted?

2006-05-29 Thread nate
As I said, you can call the association whatever you want, as long as you set the approriate array keys. If your table uses a primary key other than 'id', you can set it in your model as follows: var $primaryKey = 'WhateverID'; I'm going to assume this is your problem, since it looks like you u

Re: associations assoc. array keys too restricted?

2006-05-29 Thread GregL
In my case I had a model class "MusicDetails" which in turn had an association with Composers. When I had class Music extends Item { var $name = 'Music'; var $belongsTo = array( 'Details' => // not 'MusicDetails' array('className' =>

Re: associations assoc. array keys too restricted?

2006-05-29 Thread nate
You can call both the association name and the class name whatever you want. In fact, if the association name and class name are the same, the 'className' key is not required. The association name defines the name of the key that is returned in query results, so you can use whatever you want for

Re: associations assoc. array keys too restricted?

2006-05-29 Thread nate
You can call both the association name and the class name whatever you want. In fact, if the association name and class name are the same, the 'className' key is not required. The association name defines the name of the key that is returned in query results, so you can use whatever you want for

associations assoc. array keys too restricted?

2006-05-29 Thread GregL
In an association, today for me it was $belongsTo, I learned that the associative array you make is required to re-use the class name for both the className field and the key of the assoc. array, like this: class Music extends Item { var $name = 'Music'; var $belongsTo = array(