0

I have a model Fix with a relationship HABTM Device model. Device model has a belongsTo to Device_type model, like this, for only getting the device type name:

var $belongsTo = array('Device_type'=>array('fields'=>'name'));

So, I need every Fix, its devices and its Device_types. When I make a Fix->find('all', array('recursive' => 2)) I expect to get every Device related to Fix (this works ok) and ALSO for every device, its Device_type.name (which is not working). This is what I get instead for every Device in the result (an empty array):

["Device_type"]=>
    array(0) {
}

Besides this, when I make this query for testing: Fix->Device->find('all'), it returns the current Device_type.names for every device related to fixes, which means models are related propertly.

Any help? Thanks.

Ish
  • 28,486
  • 11
  • 60
  • 77

2 Answers2

0

First thing I notice, is your naming conventions should be lower case under_score for your multi-word table names.

And its also apparent your relationships most likely are not set up correctly if you are not getting the data on a recursive 2.

It's kind of hard to make more judgement with your limited code.

OldWest
  • 2,355
  • 7
  • 41
  • 61
  • My table names are correctly in lower case, as far as I know this names are related to models and are set as cake expected them to be. Obvioulsy, there could be a problem with my relationships, that is why I am asking for your help and knowledge, since I am new to cakePhp. There is not really much more coding than I mentioned here, anyway I am still asking for someone's help and a valuable answer. – Cynthia Feb 18 '11 at 10:58
0

If you are new to CakePHP and MVC, it would be really best to follow the blog tutorial on the CakePHP web site. From that, you will learn the basics of building a CakePHP app and in the end have working application which you can "play" with and modify to learn how MVC ticks. You can experiment and learn a lot from this : )

OldWest
  • 2,355
  • 7
  • 41
  • 61