/** * Handle a bulk toggle * * @param \Cake\ORM\Query|null $query The query to act upon * @return bool */ protected function _bulk(Query $query = null) { $field = $this->config('field'); $expression = [new QueryExpression(sprintf('%1$s= NOT %1$s', $field))]; $query->update()->set($expression); $statement = $query->execute(); $statement->closeCursor(); return $statement->rowCount(); }
/** * Handle a bulk value set * * @param \Cake\ORM\Query|null $query The query to act upon * @return bool */ protected function _bulk(Query $query = null) { $field = $this->config('field'); $value = $this->config('value'); $query->update()->set([$field => $value]); $statement = $query->execute(); $statement->closeCursor(); return $statement->rowCount(); }