Saturday, September 26, 2009

Re: simple "contain" question

On Sat, Sep 26, 2009 at 9:38 AM, lorenx <lorenx@gmail.com> wrote:
>
> sorry...
>
> and if i need something like this
>
> 'contain' => array(
>       'DpageStruct' => array(
>               'DpageStructField' => array(
>                       'DpageField' => array(
>                               'Language'
>                       ),
>                       'HtmlInputType',
>                       'order' => $this->OtherModel->order
>               )
>       )
> )
>
> is that the correct way to refer to the OtherModel property or not...

Yes and no. You can refer to it as $this->OtherModel->order IF your
model has a class var $order. But the order option shouldn't be inside
your contain array, anyway.

$this->YourModel->find(
'all',
array(
'order' => $this->TheModel->order,
'contain' => $this->TheModel->contain
)
);

Besides, even if you could put the 'order' option inside the 'contain'
array, it still wouldn't work if you also want to use a class var
$contain. ie, it wouldn't work because you can't do (in the model)

var $order = array(...);

var $contain = array(
'DpageStruct' => array(
'DpageStructField' => array(
'DpageField' => array(
'Language'
),
'HtmlInputType',
'order' => $this->order
)
)
);

That would trigger a fatal error because you're defining a class
variable yet using the keyword $this, which is inappropriate (there's
no instance of the model at this point).

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: