>
> 1) I dont have 'Result.measurement_id' since "Result hasMany
> Measurement "
Sorry, I was thinking about that backwards.
var $paginate = array(
'Measurement' => array(
'limit' => 10,
'page' => 1,
'order' => array('Measurement.created' => 'DESC'),
'fields' => array(
'Measurement.id', 'Measurement.result_id'
),
'contain' => array(
'Result' => array(
'fields' => array(
'Result.id', 'Result.chip_id'
),
'Chip' => array(
'fields' => array(
'Chip.id'
)
)
)
)
);
> 2) I followed your instructionsand right now my contain array looks
> like this:
> Array
> (
> [Type] => Array
> (
> [fields] => Array
> (
> [0] => Type.name
> )
>
> )
>
> [Result] => Array
> (
> [fields] => Array
> (
> [0] => Result.chip_id
> )
>
> [Chip] => Array
> (
> [fields] => Array
> (
> [0] => Chips.corner
> [1] => Chip.id
> )
>
> )
>
> )
>
> )
Where did Type come from? How is that associated to any of these other models?
> I'm looking to add a constraint to my query: Chips.corner = $value
In that case, I /think/ you could add the condition under the Chip
array. Obviously, that can't be declared in the class var but you
could add it to the $paginate array in the controller method:
$this->paginate['Measurement']['contain']['Chip']['conditions'] =
array('Chip.corner' => $value);
... but I'm not 100% confident that it'll work. I've done some things
like that before but can't, offhand, remember quite what I did. Try it
anyway.
Other options would be to add a 'joins' array or to use bindModel. But
until we know more about Type it's difficult to give any examples.
> 3) I still use
> $this->paginate = array(
> //'recursive' => 2,
> 'conditions' => $conditions,
> 'contain' => $contain
> );
> instead of var $paginate... since I'm building a filter page for a
> table(for measurements) so I'm building the contain array dynamically
> from input from the page.
> Its not suppose to be a problem right?
It's perfectly valid. But you should declare $paginate with the bare
essentials, then modify the array in the method.
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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:
Post a Comment