Returns 0 if this was loaded from the DB, 1 if from 1st level cache and 2 if 2nd level cache
@access     public
@param      bool (optional) if provided will change the value
@return     bool
332186
public function CacheLevel($value = null)
	{
		if ($value != null) $this->_cacheLevel = $value;
		return $this->_cacheLevel;
	}
918264
public function getValue($query)
    {
        $this->statement = $this->db->query($query);
        if ($this->statement) {
            $value = $this->statement->fetch(\PDO::FETCH_BOTH);
            if (!empty($value[0])) {
                return $value[0];
            }
        }
        return false;
    }
489567
public function IsPartiallyLoaded($value = null)
	{
		if ($value != null) $this->_isPartiallyLoaded = $value;
		return $this->_isPartiallyLoaded;
	}
865255
public function numChildren($cache = true)
    {

        $baseClass = $this->owner->baseClass();
        $cacheType = 'numChildren';
        $id = $this->owner->ID;

        // cached call
        if ($cache) {
            if (isset(self::$cache_numChildren[$baseClass][$cacheType][$id])) {
                return self::$cache_numChildren[$baseClass][$cacheType][$id];
            } elseif (isset(self::$cache_numChildren[$baseClass][$cacheType]['_complete'])) {
                // If the cache is complete and we didn't find our ID in the cache, it means this object is childless.
                return 0;
            }
        }

        // We call stageChildren(), because Children() has canView() filtering
        $numChildren = (int)$this->owner->stageChildren(true)->Count();

        // Save if caching
        if ($cache) {
            self::$cache_numChildren[$baseClass][$cacheType][$id] = $numChildren;
        }

        return $numChildren;
    }
418931
protected function loadCache()
    {

        if (empty($this->cacheListing)) return false;

        foreach ($this->cacheListing as $key => $entry) {
            if (!$entry) {
                continue;
            }


            if (!($entry instanceof Entry)) {
                /** @var $entry Entry */
                unset($entry);
                continue;
            }

            /** @var $entry Entry */
            if (!$entry->getId()) {
                unset($this->cacheListing [$key]);
                continue;
            }

            // if there is no value or the time to live is exceeded
            // unset the index and if necessary allocated the memoryblock
            if (!$entry->getData() || ($entry->getTtl() !== self::TTL_UNLIMITED && $entry->getTtl() < time())) {
                if ($entry instanceof Entry) {
                    $entry->delete();
                }

                unset($this->cacheListing [$key]);
                continue;
            }

            $this->list [$key] = $entry->getData();
        }

        return true;
    }
1302338
function result()
    {
        if ($this->result == null || count($this->result) == 0) {
            return false;
        }
        return $this->result;
    }
759941
public function hasPendingChangesets()
    {
        $qb = $this->createQueryBuilder('ac')
            ->select('count(ac)')
            ->where('ac.status = :status')
            ->setParameter('status', AclChangeset::STATUS_NEW);

        return $qb->getQuery()->getSingleScalarResult() != 0;
    }
486562
public function clear(): bool {
        $this->heap = \array_fill(0, $this->maxSize, null);
        $this->heap[0] = \PHP_INT_MIN;
        return \count($this->heap) === 1 && $this->heap[0] === \PHP_INT_MIN;
    }
385412
private function cacheOrFetchResult($url)
    {
        if ($this->cache !== false) {
            /** @var AbstractCache $cache */
            $cache = $this->cache;
            $cache->setSeconds($this->seconds);
            if ($cache->isCached($url)) {
                $this->wasCached = true;
                return $cache->getCached($url);
            }
            $result = $this->fetcher->fetch($url);
            $cache->setCached($url, $result);
        } else {
            $result = $this->fetcher->fetch($url);
        }
        $this->wasCached = false;

        return $result;
    }
1114960
public function first() {
		$this->limit(1);
		$result = $this->find();
		return empty($result) ? null : $result[0];
	}
1240633
protected function compare($a, $b)
    {
        if (is_null($this->comparator)) {
            if ($a < $b) {
                return -1;
            }
            if ($a > $b) {
                return 1;
            }
            return 0;
        }

        return call_user_func($this->comparator, $a, $b);
    }
330261
public function hasChange()
    {
        foreach ($this as $key => $value) {
            if ($this->isAdded || $this->isDeleted) {
                return true;
            }
        }

        return false;
    }
1062722
public function checkExistence()
    {
        if (empty($this->primaryKey)) {
            return false;
        }

        return static::find()->pk($this->primaryKey)->count() > 0;
    }
872155
public function affected_rows($result = null)
    {
        if ($result || ($result === null && ($result = $this->last_result))) {
            return oci_num_rows($result);
        }

        return 0;
    }
380969
public function first()
    {
        $results = $this->get();

        if (is_array($results) && array_key_exists(0, $results)) {
            return $results[0];
        }

        // No entries were returned, return false
        return false;
    }
261605
public function affected_rows($result = null)
    {
        if ($result || ($result === null && ($result = $this->last_result))) {
            if ($result !== true) {
                return $result->rowCount();
            }
        }

        return 0;
    }
1207793
public function zeroFill($a, $b)
    {
        return ($a >= 0) ? ($a >> $b) : ($a >> $b) & (PHP_INT_MAX >> ($b - 1));
    }