$sql = "SELECT id FROM myTable WHERE id IN " . $list; $results = $modx->query($sql);
This question has been answered by multiple community members. See the first response.
$myArr = array(11,22,33);
$sql = "SELECT id FROM myTable";javascript:void(0);
$all = $modx->query($sql);
$results = $all->where(array(
"id:IN" => $myArr
));
$myArr = array(11,22,33);
$classname = 'yourXpdoClass';
$c = $modx->newQuery($classname);
$c->where(array("id:IN" => $myArr));
if ($collection = $modx->getCollection($classname,$c)){
foreach ($collection as $object){
$object->set('yourfield',$yourvalue);
$object->save();
}
}$myArr = array(11,22,33);
$classname = 'yourXpdoClass';
$c = $modx->newQuery($classname);
$c->where(array("id:IN" => $myArr));
$c->prepare();
if ($c) {
while($row = mysql_fetch_assoc($c)) {
echo print_r($row, true);
}
}
Indeed I would like to avoid the whole arsenal of xPDO for this rather simple task
$myArr = array(11,22,33);
$classname = 'myXpdoClass';
$c = $modx->newQuery($classname);
$c->where(array("id:IN" => $myArr));
$c->prepare();
print $c->toSQL();
SELECT `` FROM WHERE ``.`id` IN ('11','22','33')
if ($collection = $modx->getCollection('$classname',$c))$packageName = 'yourpackage';
$prefix = null;
$packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
$modelpath = $packagepath . 'model/';
if (is_dir($modelpath)) {
$modx->addPackage($packageName, $modelpath, $prefix);
}