Here are my tables:

CREATE TABLE `registered_states` (
   `state_id` int(11) NOT NULL default '0',
   PRIMARY KEY  (`state_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1

CREATE TABLE `states` (
   `id` int(11) NOT NULL auto_increment,
   `name` varchar(24) NOT NULL default '',
   `code` char(2) NOT NULL default '',
   PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1


Models:

// registered_state.php
class RegisteredState extends AppModel
{
    var $name = 'RegisteredState';
        
        var $hasMany = array('State' =>
                          array('className'     => 'State',
                                'conditions'    => '',
                                'order'         => '',
                                'limit'         => '',
                                'foreignKey'    => 'state_id',
                                'dependent'     => false,
                                'exclusive'     => false,
                                'finderQuery'   => ''
                          )
                   );
                                                
        
}

// state.php
class State extends AppModel
{
     var $name = 'State';
     var $validates = array('code' => VALID_NOT_EMPTY);
        

}


-Erich-

Christopher E. Franklin, Sr. wrote:
> Post your model code with the names of the files and where they are
> located.
> 
> On Feb 10, 6:12 pm, "Erich C. Beyrent" <[EMAIL PROTECTED]>
> wrote:
>> That did not work - now I get:
>>
>> Array
>> (
>>      [0] => Array
>>          (
>>              [RegisteredState] => Array
>>                  (
>>                      [state_id] => 10
>>                  )
>>
>>              [State] => Array
>>                  (
>>                  )
>>
>>          )
>> )
>>
>> I know I can write my own custom query for this, but I am unsure as to
>> why this isn't working for me.
>>
>> -Erich-
>>
>> djiize wrote:
>>> in registered_states table, try state_id (not plural)
>>> On 9 fév, 19:10, "Erich C. Beyrent" <[EMAIL PROTECTED]> wrote:
>>>> I am trying to link two tables, states and registered_states.
>>>> The states table has id, name, and code as fields, and registered_states
>>>> has states_id.
>>>> I defined as hasMany association in the registered_states model, and now
>>>> want to produce a list of all the registered states and their associated
>>>> state.
>>>> I'm getting the list of registered states, but no state data:
>>>> Array
>>>> (
>>>>      [0] => Array
>>>>          (
>>>>              [RegisteredState] => Array
>>>>                  (
>>>>                      [states_id] => 10
>>>>                  )
>>>>              [State] => Array
>>>>                  (
>>>>                  )
>>>>          )
>>>> )
>>>> What I'm particularly interested in retrieving is the state code for
>>>> each registered state.
>>>> How can I accomplish this?
>>>> -Erich-
> 
> 
> > 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to