ModifierTrait::updateRecordStatusMany

@param array $ids

@return bool|int
356206
private function updateRecordStatusMany(array $ids, $recordStatus, $method)
    {
        if (count($ids)) {
            $sets[ 'record_status' ] = $recordStatus;
            $primaryKey = isset($this->primaryKey) ? $this->primaryKey : 'id';

            $this->qb->whereIn($primaryKey, $ids);

            if (method_exists($this, 'updateRecordSets')) {
                $this->updateRecordSets($sets[ $key ]);
            }

            if (method_exists($this, $beforeMethod = 'before' . ucfirst($method))) {
                call_user_func_array([&$this, $beforeMethod], [$sets]);
            }

            if ($this->qb->table($this->table)->update($sets)) {
                if (method_exists($this, $afterMethod = 'after' . ucfirst($method))) {
                    return call_user_func([&$this, $beforeMethod]);
                }

                return $this->getAffectedRows();
            }
        }

        return false;
    }
312269
public function run($ids) {

        if (!empty($ids)) {
            $attachementClass = $this->attachementClass;
            $sortIds = explode(',', $ids);
            $count = count($sortIds);
            for ($i = 0; $i < $count; $i++) {
                $positon = $count - $i;
                $model = $attachementClass::findOne(['id' => $sortIds[$i]]);
                if ($model) {
                    $model->updateAttributes(['position' => $positon]);
                }
            }

            if ($this->onComplete) {
                return call_user_func($this->onComplete, $sortIds);
            }
        }

        $responseData = ResponseDatum::getSuccessDatum(['message' => Yii::t('cza', 'Operation completed successfully!')], $ids);
        return $this->controller->asJson($responseData);
    }
824051
public function update(array $sets, $conditions = [])
    {
        if (count($sets)) {
            $primaryKey = isset($this->primaryKey) ? $this->primaryKey : 'id';

            if (empty($conditions)) {
                if (isset($sets[ $primaryKey ])) {
                    $conditions = [$primaryKey => $sets[ $primaryKey ]];
                }
            }

            if (method_exists($this, 'updateRecordSets')) {
                $this->updateRecordSets($sets);
            }

            if (method_exists($this, 'beforeUpdate')) {
                $sets = $this->beforeUpdate($sets);
            }

            if (method_exists($this, 'getRecordOrdering')) {
                if ($this->recordOrdering === true && empty($sets[ 'record_ordering' ])) {
                    $sets[ 'record_ordering' ] = $this->getRecordOrdering($this->table);
                }
            }

            if ($this->qb->table($this->table)->update($sets, $conditions)) {

                if (method_exists($this, 'afterUpdate')) {
                    return $this->afterUpdate();
                }

                return true;
            }
        }

        return false;
    }
771703
public static function updateById($id, array $record, array $params = [])
    {
        $m = new static;
        $pk = $m->getPrimaryKey();
        $record[$pk] = $id;

        try {
            $response = static::bulkUpdate([$record], $params);

            return current($response);
        } catch (BatchException $ex) {
            $response = $ex->pickResponse(0);
            if ($response instanceof \Exception) {
                throw $response;
            }

            return $response;
        } catch (\Exception $ex) {
            throw new InternalServerErrorException($ex->getMessage());
        }
    }
52293
public function get_from_ids(array $ids) {
        $alias = $this->get_table_alias();
        list($insql, $params) = $this->get_db()->get_in_or_equal($ids);
        $wheresql = $alias . '.id ' . $insql;
        $sql = $this->generate_get_records_sql($wheresql);
        $records = $this->get_db()->get_records_sql($sql, $params);

        return $this->transform_db_records_to_entities($records);
    }
514469
public function ids($ids)
    {
        $ids = is_array($ids) ? $ids : [$ids];

        $query = new IdsQuery($ids);

        $this->append($query);

        return $this;
    }
142667
public function update(array $values)
    {
        // update timestamps
        $values = $this->addUpdatedAtColumn($values);

        // get version values & values
        $versionValues = $this->getVersionValues($values);
        $values = $this->getValues($values);

        // get records
        $affectedRecords = $this->getAffectedRecords();

        // update main table records
        if (! $this->query->increment($this->model->getLatestVersionColumn(), 1, $values)) {
            return false;
        }

        // update version table records
        $db = $this->model->getConnection();
        foreach ($affectedRecords as $record) {
            // get versioned values from record
            foreach($this->model->getVersionedAttributeNames() as $key) {
                $recordVersionValues[$key] = (isset($versionValues[$key])) ? $versionValues[$key] : $record->{$key};
            }

            // merge versioned values from record and input
            $recordVersionValues = array_merge($recordVersionValues, $versionValues);

            // set version and ref_id
            $recordVersionValues[$this->model->getVersionKeyName()] = $record->{$this->model->getKeyName()};
            $recordVersionValues[$this->model->getVersionColumn()] = $record->{$this->model->getLatestVersionColumn()}+1;

            // insert new version
            if(! $db->table($this->model->getVersionTable())->insert($recordVersionValues)) {
                return false;
            }
        }

        // fill the latest version value
        $this->model->{$this->model->getLatestVersionColumn()} += 1;

        return true;
    }
1279992
public function in($id, array $ids)
    {
        $allParents = $this->getHierarchy($id);

        /**
         * To increase the efficiency, we can index the results of the parent.
         */
        $allParentsIndexed = [];
        foreach ($allParents as $parent) {
            $allParentsIndexed[$parent->getId()] = $parent;
        }

        foreach ($ids as $possibleParentId) {
            if (isset($allParentsIndexed[$possibleParentId])) {
                return true;
            }
        }

        return false;
    }
236863
public function load($ids)
    {
        settype($ids, 'array');

        $types = $this->getTypes();
        $libraries = $this->getList();

        foreach ($ids as $key => $id) {

            if ($this->isLoaded($id)) {
                unset($ids[$key]);
                continue;
            }

            if (empty($libraries[$id]['type'])) {
                unset($ids[$key]);
                continue;
            }

            if (empty($types[$libraries[$id]['type']]['load'])) {
                unset($ids[$key]);
            }
        }

        $sorted = $this->graph->sort($ids, $libraries);

        if (empty($sorted)) {
            return false;
        }

        foreach ($this->prepareFiles($sorted, $libraries) as $file) {
            require_once $file;
        }

        $this->loaded = array_merge($this->loaded, $sorted);
        return true;
    }
96556
public function findMany($ids, array $columns = ['*'])
    {
        if (empty($ids)) {
            return $this->model->newCollection();
        }

        $this->getBuilder()->whereIn($this->getModel()->getQualifiedKeyName(), $ids);

        return $this->get($columns);
    }
648272
public function setModified($ids)
    {
        $write     = $this->getConnection();
        $tableName = $this->getTable(Schema::EMAIL_CATALOG_TABLE);
        $write->update(
            $tableName,
            ['modified' => 1],
            [
                $write->quoteInto("product_id IN (?)", $ids),
                $write->quoteInto("imported = ?", 1)
            ]
        );
    }
1151552
final public function deleteByPks(array $ids)
    {
        foreach ($ids as $id) {
            if (!$this->deleteByPk($id)) {
                return false;
            }
        }

        return true;
    }
220333
protected function updateJob(ObjectId $id, int $status): UpdateResult
    {
        $result = $this->db->{$this->job_queue}->updateMany([
            '_id' => $id,
            '$isolated' => true,
        ], [
            '$set' => [
                'status' => $status,
            ],
        ]);

        return $result;
    }
633842
public function findMany($ids, $columns = ['*'])
    {
        if (empty($ids)) {
            return $this->model->newCollection();
        }

        return $this->whereKey($ids)->get($columns);
    }
366356
public function update(array $values)
    {
        // migrate the collection, if needed
        Schema\Builder::getInstance()->dynamic($this->query->getModel(), $values);

        $allowed = $this->fireEvent('updating_multiple', array($this, $values));

        if ($allowed === false) {
            return false;
        } elseif (is_array($allowed)) {
            $values = $allowed;
        }

        $result = $this->query->update($values);
        $this->fireEvent('updated_multiple', array($this, $values));

        return $result;
    }
488600
public function massResend($ids)
    {
        try {
            $conn = $this->getConnection();
            $num = $conn->update(
                $this->getTable(Schema::EMAIL_IMPORTER_TABLE),
                ['import_status' => 0],
                ['id IN(?)' => $ids]
            );

            return $num;
        } catch (\Exception $e) {
            return $e->getMessage();
        }
    }
997460
private function updateChildren(array $ids)
    {
        if (count($ids) < 1) {
            return;
        }

        foreach ($ids as $id) {
            $alias = $this->db->fetchColumn('SELECT alias FROM tl_page WHERE id=?', [$id]);
            $alias = $this->cleanAlias($alias);

            $this->db->update('tl_page', ['alias' => $alias], ['id' => $id]);
        }
    }