Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot user WHERE id IN (multiple number) #91

Open
maartenvr98 opened this issue Sep 28, 2016 · 3 comments
Open

Cannot user WHERE id IN (multiple number) #91

maartenvr98 opened this issue Sep 28, 2016 · 3 comments

Comments

@maartenvr98
Copy link

$id = "1,2,3,4";
$ids = implode(",", $id);
$sql = $db->query("UPDATE " . DB_PREFIX . "users SET status = " . $status . " WHERE id IN (:id)", array("id"=>$ids));

Only the first id in $idswill be updated

@RiccardoB
Copy link

I’m looking for a method to use the IN statement too.
At this moment the only way I’ve found to use a IN is to manually write the query skipping the bind (that is not the "right" solution).

@waliddoch
Copy link

Same here!
Is there any way to use the IN option for queries?

@derBoehm
Copy link

Im using this

/** * @void * * Add parameters for IN() to the parameter array * @param array for IN( ARRAY_LIST ) */ public function bindArray($prefix="filter_", $values) { $str = ""; foreach($values as $index => $value) { $str .= ":".$prefix.$index.","; $bindArray[$prefix.$index] = $value; $this->bind($prefix.$index, $value); } return rtrim($str,","); }

`$x = $db->bindArray(yourArray)
$sql = $db->query("UPDATE " . DB_PREFIX . "users SET status = " . $status . " WHERE id IN ({$x})");`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants