hey dood,
what do you mean by this exactly?
"I can't figure out how to fill in the values from a variable..."
If you've set up your form to pass the id's as an array :
<input type="checkbox" name="data[Object][id][]" value="1" />
<input type="checkbox" name="data[Object][id][]" value="2" />
<input type="checkbox" name="data[Object][id][]" value="3" />
when you reference :
$this->data['Object']['id']
In your controller it should already be an array. Then you could do
something like :
$conditions = array (
'Object.id' => $this->data['Object']['id']
);
Which will then allow Cake to create the WHERE / IN statement.
Does that make sense?
HTH,
mikee
On 13/02/07, digitalcowboy <[EMAIL PROTECTED]> wrote:
>
> I appreciate the help but I already have that part. The values in
> that array are any possible combination of 10 coming from the
> checkboxes in the form. I'm trying to do exactly what you suggest but
> I can't figure out how to fill in the values from a variable without
> Cake converting them to a string.
>
> On Feb 12, 11:26 am, "djiize" <[EMAIL PROTECTED]> wrote:
> > to to a IN query, do this:
> > $criteria['Bid.industry_id'] = array(400,402,403); // free to you to
> > populate the array
> > $this->Bid->findAll($criteria);
> >
> > it will automagically do:
> > ... WHERE Bid.industry_id IN (400, 402, 403);
> >
> > On 12 fév, 17:45, "BlenderStyle" <[EMAIL PROTECTED]> wrote:
> >
> > > You could probably get around this with the query method for the
> > > model.
> >
> > > $this->Model->query($custom_query);
> >
> > > On Feb 12, 5:44 am, "digitalcowboy" <[EMAIL PROTECTED]> wrote:
> >
> > > > I wasn't sure how to title this. Here's my challenge:
> >
> > > > I have an array of 10 checkboxes to select categories for a search.
> > > > The checkboxes are passing INT values from the form. The search
> > > > function then needs to apply the checked catgeories as conditions on
> > > > the query. I couldn't figure out how to pass an array as the
> > > > $conditions value itself. The closest I've been able to come is doing
> > > > an implode on the array to create a string for $conditions. The
> > > > problem is that the array values and, more importantly, the field the
> > > > condition is applied to are INT. Cake is building the query like so:
> >
> > > > ... WHERE (`Bid`.`industry_id` IN ('400,402,403') )
> >
> > > > That's fine except that MySQL seems to be choking because of the
> > > > single quotes and only searching on the first value (WHERE industry_id
> > > > = 400 in this example). I confirmed this by running the query
> > > > directly against the database. After removing the single quotes
> > > > around the list of INTs - [WHERE (`Bid`.`industry_id` IN
> > > > (400,402,403) )] - it finds everything as it should.
> >
> > > > Long way to get to this question: Is there any way I can pass an
> > > > array of INTs for the $conditions on findAll instead of a string or
> > > > get MySQL to properly accept the array of INTs in string form?
> >
> > > > Thanks in advance.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---