Never mind. I'd started adding debug() calls in containable.php and
never saw them printed. Then I realised that I'd forgotten to create
my own AppModel with $actsAs = array('Containable'); Aaaargghh!

Now I've got to take a closer look at this latest model.php to figure
out why *some* of the 'contain' arrays were being used. Confusing ...

On Tue, Sep 15, 2009 at 10:48 AM, brian <bally.z...@gmail.com> wrote:
> Using 1.2.5
>
> I'm having some trouble get a deep containment (PresentationFile) to
> show up. No matter what I've tried, I only get Presentations. Can
> anyone see something wrong with the following?
>
> event.php
> class Event extends AppModel
> {
>  public $belongsTo = array('Country');
>  public $hasMany = array('Report', 'Presentation');
> }
>
> presentation.php:
> class Presentation extends AppModel
> {
>  public $belongsTo = array('Event');
>  public $hasMany = array(
>    'PresentationFile' => array(
>      'className' => 'PresentationFile',
>      'foreignKey' => 'presentation_id',
>      'dependent' => true
>    )
>  );
> }
>
> presentation_file.php:
> class PresentationFile extends AppModel
> {
>  public $useTable = 'presentation_files';
>  public $belongsTo = array('Presentation');
> }
>
> events_controller.php:
> class EventsController extends AppController
> {
>  public $paginate = array(
>    'Event' => array(
>      'fields' => array('*'),
>      'conditions' => array('Event.start_date < NOW()'),
>      'order' => array('Event.start_date' => 'DESC'),
>      'limit' => 10,
>      'contain' => array(
>        'Country',
>        'Report' => array(
>          'fields' => array('Report.id', 'Report.title')
>        ),
>        'Presentation' => array(
>          'fields' => array(
>            'Presentation.id',
>            'Presentation.event_id',
>            'Presentation.title',
>            'Presentation.presenter'
>          ),
>          'PresentationFile' => array(
>            'fields' => array(
>              'PresentationFile.id',
>              'PresentationFile.presentation_id',
>              'PresentationFile.directory',
>              'PresentationFile.basename',
>              'PresentationFile.size'
>            )
>          )
>        )
>      )
>    )
>  );
>
>  public function index()
>  {
>    $this->set('events', $this->paginate('Event'));
>  }
> }
>
>
> Debug shows the following:
>
> Array
> (
>  [0] => Array
>    (
>      [Event] => Array
>        (
>          [id] => 8
>          [title] => xxxxxx
>          [subtitle] =>
>          [start_date] => 2008-09-03
>          [end_date] => 2008-09-03
>          [venue] =>
>          [city] => Prague
>          [country_id] => 58
>          [full_date] => September 3, 2008
>        )
>
>      [Country] => Array
>        (
>          [id] => 58
>          [iso_code] => CZ
>          [name] => Czech Republic
>        )
>
>      [Report] => Array
>        (
>        )
>
>      [Presentation] => Array
>        (
>          [0] => Array
>            (
>              [id] => 117
>              [created] => 2008-09-01 00:00:00
>              [modified] => 2009-09-13 12:44:56
>              [event_id] => 8
>              [title] => xxxxxx
>              [slug] => xxxxxx
>              [presenter] => xxxxxx
>            )
>
>          [1] => Array
>            (
>              [id] => 118
>              [created] => 2008-09-01 00:00:00
>              [modified] => 2009-09-13 12:44:56
>              [event_id] => 8
>              [title] => xxxxxx
>              [slug] => xxxxxx
>              [presenter] => xxxxxx
>            )
>
> (etc.)
>
> There are DB records in presentation_files with presentation_id for
> each of the Presentations.
>
> Oddly, no matter what I put in the 'fields' array for Presentation, I
> get all fields. This led me to believe that the problem was with the
> cache, but that's been disabled and all cached files removed.
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to