Recursive function. Updates quantity of sold articles.
Return true if amount was changed in database.

@param float $dAmount Number of articles sold

@return mixed
422740
public function updateSoldAmount($dAmount = 0)
    {
        if (!$dAmount) {
            return;
        }

        // article is not variant - should be updated current amount
        if (!$this->oxarticles__oxparentid->value) {
            //updating by SQL query, due to wrong behaviour if saving article using not admin mode
            $dAmount = (double) $dAmount;
            $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
            $rs = $oDb->execute("update oxarticles set oxarticles.oxsoldamount = oxarticles.oxsoldamount + $dAmount where oxarticles.oxid = " . $oDb->quote($this->oxarticles__oxid->value));
        } elseif ($this->oxarticles__oxparentid->value) {
            // article is variant - should be updated this article parent amount
            $oUpdateArticle = $this->getParentArticle();
            if ($oUpdateArticle) {
                $oUpdateArticle->updateSoldAmount($dAmount);
            }
        }

        return (bool) $rs;
    }
865220
public function AddArticle($sArticleId, $dAmount = 1, $sComment = null)
    {
        $dNewAmount = 0;
        $aItemData = array();
        $oItem = TdbPkgShopWishlistArticle::GetNewInstance();
        /** @var $oItem TdbPkgShopWishlistArticle */
        if ($oItem->LoadFromFields(array('pkg_shop_wishlist_id' => $this->id, 'shop_article_id' => $sArticleId))) {
            $aItemData = $oItem->sqlData;
            $aItemData['amount'] += $dAmount;
        } else {
            $aItemData['pkg_shop_wishlist_id'] = $this->id;
            $aItemData['shop_article_id'] = $sArticleId;
            $aItemData['amount'] = $dAmount;
            $aItemData['datecreated'] = date('Y-m-d H:i:s');
        }
        if (!is_null($sComment)) {
            $aItemData['comment'] = $oItem->LoadFromRow($aItemData);
        }
        $oItem->LoadFromRow($aItemData);
        $oItem->AllowEditByAll(true);
        $oItem->Save();
        $dNewAmount = $aItemData['amount'];

        return $dNewAmount;
    }
1295017
public function changeStatus($newStatus)
    {
        if ($this->owner->hasAttribute($this->statusAttribute)) {
            $oldStatus = $this->owner->{$this->statusAttribute};
            if ($this->isTransitionAllowed($oldStatus, $newStatus)) {
                $this->owner->{$this->statusAttribute} = $newStatus;
                return $this->owner->save(true, array($this->statusAttribute));
            }
        }
        return false;
    }
59185
public function executePayment($dAmount, & $oOrder)
    {
        /** @var oxUserPayment|OxpsPaymorrowOxUserPayment $oUserPayment */
        $oUserPayment = $this->_oPaymentInfo;

        if (is_object($oUserPayment) && $oUserPayment->isUserPaymentPaymorrowMethod()) {

            // Set real order ID (OXID field) to session to be used in order confirmation during payment.
            $oOrderId = $oOrder->getId();
            $oOrder->savePaymorrowTemporaryOrderIdToSession($oOrderId);

            /** @var OxpsPaymorrowModule $oModule */
            $oModule = oxRegistry::get('OxpsPaymorrowModule');

            /** @var OxpsPaymorrowRequestControllerProxy $oPmRequestControllerProxy */
            $oPmRequestControllerProxy = oxNew('OxpsPaymorrowRequestControllerProxy');
            $oPmRequestControllerProxy->confirmOrder($oModule->getPaymentMethodName(), $oOrderId);

            /** @var OxpsPaymorrowResponseHandler $oPmResponseHandler */
            $oPmResponseHandler = oxRegistry::get('OxpsPaymorrowResponseHandler');

            /**
             * If Order has an error after validation from Paymorrow services invalidate order and delete it
             * If Payment data save failed return an error
             */
            if ($oPmResponseHandler->hasErrors() or
                !$this->_savePaymorrowUserPaymentData($oOrder, $oPmResponseHandler)
            ) {
                $this->_handleOrderResponseErrors($oPmResponseHandler);

                return false;
            }
        }

        return $this->_OxpsPaymorrowOxPaymentGateway_executePayment_parent($dAmount, $oOrder);
    }
514487
public function chunk( $count, callable $callback )
	{
		$results = $this->forPage( $page = 1, $count )->get();

		while ( count( $results ) > 0 )
		{
			// On each chunk result set, we will pass them to the callback and then let the
			// developer take care of everything within the callback, which allows us to
			// keep the memory low for spinning through large result sets for working.
			if ( call_user_func( $callback, $results ) === false )
			{
				return false;
			}

			$page++;

			$results = $this->forPage( $page, $count )->get();
		}

		return true;
	}
455648
public function each(callable $callback, $count = 1000)
    {
        $result = $this->getBuilder()->each($callback, $count);

        // Reset query builder
        $this->resetBuilder();

        return $result;
    }
398775
public function updateMultiple($docs) {
		$request = new CPS_UpdateRequest($docs);
		$this->_lastResponse = $this->_connection->sendRequest($request);
		return count($this->_lastResponse->getModifiedIds());
	}
796343
public function countAllResults($reset = true)
    {
        $cursor = $this->conn->server->executeCommand('neo_app',
            new \MongoDb\Driver\Command(['count' => 'posts']));

        $result = current($cursor->toArray());

        $totalDocuments = 0;

        if (isset($result->n)) {
            $totalDocuments = (int)$result->n;
        }

        return $totalDocuments;
    }
1111903
public function setNumTotalResults( $total )
	{
		$total = (int)$total;
		if ( $total < 0 )
		{
			trigger_error( 'Pagination setNumTotalResults: Total must be positive.' );
			return false;
		}

		$this->items_total = $total;
	}
751445
public function update () : bool
	{
        $dbObject 	= Database::getInstance();
		$sqlQuery 	= "UPDATE ".static::$tableName." SET ".$this->generateQueryForUPdate();
		$sqlQuery  .= " WHERE id = ". $dbObject->escapeValue($this->id);
		$result 	= $dbObject->query($sqlQuery);
    	return ($result) ? TRUE : FALSE;
	}
957077
protected function updateInternal($attributes = null)
    {
        if (!$this->beforeSave(false)) {
            return false;
        }
        
        $values = $this->getDirtyAttributes($attributes);
        
        if (empty($values)) {
            $this->afterSave(false, $values);
            
            return 0;
        }
        
        $condition = $this->getOldPrimaryKey(true);
        $lock = $this->optimisticLock();

        if ($lock !== null) {
            if (!isset($values[$lock])) {
                $values[$lock] = $this->$lock + 1;
            }

            $condition[$lock] = $this->$lock;
        }

        // We do not check the return value of update() because it's possible
        // that it doesn't change anything and thus returns 0.
        $rows = static::getBucket()->update($values, $condition);

        if ($lock !== null && !$rows) {
            throw new StaleObjectException('The object being updated is outdated.');
        }
        
        if (isset($values[$lock])) {
            $this->$lock = $values[$lock];
        }
        
        $changedAttributes = [];
        
        foreach ($values as $name => $value) {
            $changedAttributes[$name] = $this->getOldAttribute($name);
            $this->setOldAttribute($name, $value);
        }
        
        $this->afterSave(false, $changedAttributes);
        
        return $rows;
    }
582156
public function update(array $set, $where = true)
    {
        if (empty($set)) {
            return 0;
        }
        if ($this->map) {
            $set = $this->map->set($set);
            $where = $this->map->where($where);
        }
        if ($this->fake) {
            return $this->fake->update($set, $where);
        }
        $pattern = 'UPDATE ?t SET ?sn WHERE ?w';
        $data = array($this->name, $set, $where);
        return $this->db->query($pattern, $data)->ar();
    }
1353367
public function chunk($callback, $count = 100)
    {
        if ($this->usePaginate) {
            return $this->buildData(false)->chunk($count)->each($callback);
        }

        $this->setSort();

        $this->queries->reject(function ($query) {
            return 'paginate' === $query['method'];
        })->each(function ($query) {
            $this->model = $this->model->{$query['method']}(...$query['arguments']);
        });

        return $this->model->chunk($count, $callback);
    }
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;
    }
774682
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null)
	{
		$relation = $this->getHasRelationQuery($relation);

		$query = $relation->getRelationCountQuery($relation->getRelated()->newQuery(), $this);

		if ($callback) call_user_func($callback, $query);

		return $this->addHasWhere($query, $relation, $operator, $count, $boolean);
	}
1066855
public function chunk($count, callable $callback)
    {
        $result = $this->getBuilder()->chunk($count, $callback);

        // Reset query builder
        $this->resetBuilder();

        return $result;
    }
437573
public function update($ids)
    {
        if (empty($ids)) {
            return false;
        } elseif (empty($this->_ids)) {
            $this->_ids = $ids;
            $change = true;
        } else {
            $change = false;
            foreach ($ids as $k => $v) {
                if (!isset($this->_ids[$k]) || ($this->_ids[$k] != $v)) {
                    $this->_ids[$k] = $v;
                    $change = true;
                }
            }
        }

        if ($change) {
            $this->_sorted = false;
        }

        return $change;
    }