Count the number of trans unit.

@param array $locales
@param array $filters
@return int
764065
public function count(array $locales = null,  array $filters = null)
    {
        $query = TransUnitQuery::create()
            ->select('Id')
            ->distinct()
        ;

        $this->addTransUnitFilters($query, $filters);
        $this->addTranslationFilter($query, $locales, $filters);

        return $query->count($this->getConnection());
    }
681549
public function count($conditions = null, $values = [])
    {
        $res = $this->executeQuery('COUNT(' . $this->key . ') AS num', $conditions, $values)
            ->fetch();
        return (isset($res->num) ? (int)$res->num : 0);
    }
1284614
private function resolveFilters(
        array $filters,
        $locale,
        $limit = null,
        $page = 1,
        $pageSize = null,
        $options = []
    ) {
        $result = $this->repository->findByFilters($filters, $page, $pageSize, $limit, $locale, $options);

        $hasNextPage = false;
        if (null !== $pageSize && count($result) > $pageSize) {
            $hasNextPage = true;
            $result = array_splice($result, 0, $pageSize);
        }

        return [$result, $hasNextPage];
    }
1171408
public function findAllByLocale($locale, $filter = array())
    {
        if (empty($filter)) {
            $order = $this->orderRepository->findAllByLocale($locale);
        } else {
            $order = $this->orderRepository->findByLocaleAndFilter($locale, $filter);
        }

        if ($order) {
            array_walk(
                $order,
                function (&$order) use ($locale) {
                    $order = $this->orderFactory->createApiEntity($order, $locale);
                    $this->updateApiEntity($order, $locale);
                }
            );
        }

        return $order;
    }
798276
private function doFilter(TokenFilterInterface $filter, array $tokens): array
    {
        $result = [];
        foreach ($tokens as $token) {
            $result = array_merge($result, $filter->filter($token));
        }

        return $result;
    }
289630
public function countWidgetInstances($filter = null, $organizations = null)
    {
        $qb = $this->createQueryBuilder('widget')
            ->select('COUNT(widget.id)');

        switch ($filter) {
            case 'workspace':
                $qb->where('widget.isDesktop = FALSE');
                break;
            case 'desktop':
                $qb->where('widget.isDesktop = TRUE');
                break;
            default:
                break;
        }

        if (null !== $organizations) {
            $qb->leftJoin('widget.user', 'user')
                ->leftJoin('user.userOrganizationReferences', 'orgaRef')
                ->leftJoin('widget.workspace', 'ws')
                ->leftJoin('ws.organizations', 'orgas')
                ->andWhere($qb->expr()->orX('orgaRef.organization IN (:organizations)', 'orgas IN (:organizations)'))
                ->setParameter('organizations', $organizations);
        }

        return $qb->getQuery()->getSingleScalarResult();
    }
151765
public function getCountUsers($options = [], $filters = [])
	{
		$userClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_TAO_USER);

		return $userClass->countInstances($filters, $options);
	}
535173
public function deleteTranslations( $locales = null )
    {
        if( $locales === null )
        {
            $this->translations()->delete();
        }
        else
        {
            $locales = (array)$locales;
            $this->translations()->whereIn( $this->getLocaleKey(), $locales )->delete();
        }

        // we need to manually "reload" the collection built from the relationship
        // otherwise $this->translations()->get() would NOT be the same as $this->translations
        $this->load( 'translations' );
    }
1034771
public function findAllByLocale($locale, $filter = array())
    {
        if (empty($filter)) {
            $items = $this->itemRepository->findAllByLocale($locale);
        } else {
            $items = $this->itemRepository->findByLocaleAndFilter($locale, $filter);
        }

        array_walk(
            $items,
            function (&$item) use ($locale) {
                $item = $this->itemFactory->createApiEntity($item, $locale);
            }
        );

        return $items;
    }
1224632
public function getTotalVisitCount($locale = null, $query = null)
    {
        $query = $this->determineLocaleAndQuery($locale, $query);

        return $query->count();
    }
462318
public static function getCustomersCount($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCount('/customers/count' . $filter->toQuery());
    }
494578
private function _countObjectsInCollectionByFilter(Filter $filterQuery)
    {
        $records = [];
        $props = [];
        $filters = [];
        foreach ($filterQuery->getComparisons() as $comparison) {
            $props[] = $comparison->prop;
            if ($comparison->expression && $comparison->comparison && $comparison->prop) {
                $expression = ($comparison->expression !== 'WHERE') ? $comparison->expression . ' ' : '';
                $prop = is_int($comparison->val) ? 'CAST(' . $comparison->prop . ' AS INT)' : $comparison->prop;
                $compare = $comparison->comparison;
                $value = (!isset($comparison->val) || is_null($comparison->val)) ? 'NULL' : $comparison->val;
                $filters[] = $expression . $prop . ' ' . $compare . ' \'' . $value . '\'';
            }
        }

        $props = array_unique($props);
        $joins = [];
        foreach ($props as $prop)
        {
            $standardFields = [
                '__id',
                '__type',
                '__collection',
                '__origin'
            ];
            if (!in_array($prop, $standardFields)) {
                $asTbl = $this->_generateAlphaToken();
                $joins[] =
                    'JOIN(' .
                        'SELECT id, val AS ' . $prop . ' ' .
                        'FROM ' . $this->_name . '__index ' .
                        'WHERE prop = \'' . $prop . '\'' .
                    ') AS ' . $asTbl . ' ' .
                    'ON A.id = ' . $asTbl . '.id';
            }
        }

        $select = Statement::get(
            'GET_OBJECTS_COUNT_BY_FILTER',
            [
                '@collection' => $this->_name,
                '@columns' => (count($props) > 0) ? ', ' . implode($props, ', ') : '',
                '@joinColumns' => (count($joins) > 0) ? implode($joins, ' ') . ' ' : '',
                '@type' => $this->_connector->quote($filterQuery->getIndexType()),
                '@filters' => ($filters) ? 'AND (' . implode($filters, ' ') . ') ' : ''
            ]
        );

        $count = $this->_connector->query($select)->fetch();
        if ($count) {
            return (int) $count[0];
        } else {
            return 0;
        }
    }
633946
public function findUsagesByLocales( array $locales )
    {
        $select = $this->sql()
                       ->select()
                       ->columns( array(
                           'id',
                           'name',
                           'locale',
                           'usage' => new Sql\Expression(
                                'COUNT( ?.? )',
                                array(
                                    static::$paragraphJoinTableName,
                                    'paragraphId',
                                ),
                                array(
                                    Sql\Expression::TYPE_IDENTIFIER,
                                    Sql\Expression::TYPE_IDENTIFIER,
                                )
                            ),
                        ) )
                       ->join(
                            static::$paragraphJoinTableName,
                            static::$tableName . '.id = ' .
                            static::$paragraphJoinTableName . '.tagId',
                            array(),
                            Sql\Select::JOIN_INNER
                        )
                       ->join(
                            static::$paragraphTableName,
                            static::$paragraphTableName . '.id = ' .
                            static::$paragraphJoinTableName . '.paragraphId',
                            array(),
                            Sql\Select::JOIN_INNER
                        )
                       ->where( array(
                            'paragraph.type' => 'content',
                            new Sql\Predicate\PredicateSet(
                                array(
                                    new Sql\Predicate\IsNull( 'locale' ),
                                    new Sql\Predicate\In( 'locale', $locales ),
                                ),
                                Sql\Predicate\PredicateSet::OP_OR
                            ),
                        ) )
                       ->group( array(
                           static::$tableName . '.id',
                           static::$tableName . '.name',
                           static::$tableName . '.locale',
                        ) )
                       ->order( array(
                           static::$tableName . '.name',
                           static::$tableName . '.locale',
                       ) );

        return $this->sql()
                    ->prepareStatementForSqlObject( $select )
                    ->execute();
    }
1185634
final public static function countAllObjects($filters = array()) {
	
		$app		= Application::getInstance();
		$db			= Database::getInstance();
		$class		= get_called_class();
		$binds		= $class::getBinds();
	
		$where		= '';
		$conds		= array();
		$whereLog	= '';
	
		if (is_array($filters)) {
				
			// iterate all filters
			foreach ($filters as $property => $value) {
					
				// check if filter is valid and binds really
				if (is_string($property) and strlen($property) and array_key_exists($property, $binds)) {
	
					// gets the table field name
					$field = $binds[$property];
	
					// creates where condition
					$conds[] = '`' . $field . '`' . (is_null($value) ? ' IS NULL' : ' = ' . $db->quote($value));
						
				} else {
						
					trigger_error('In method ' . $class . '::countAllObjects() unexistent property “' . $property . '” can’t be used as filter');
						
				}
					
			}
				
			// log message
			$whereLog .= count($conds) ? ' under condition ' . implode(' AND ', $conds) : '';
				
			// builds where
			$where = count($conds) ? ' WHERE ' . implode(' AND ', $conds) : '';
	
		}

		// runs query
		$db->setQuery('SELECT COUNT(1) FROM `' . $class::TABLE_NAME . '`' . $where);
		$count = $db->loadCount();
	
		$app->logEvent('Counted ' . $count . ' ' . $class . ' objects' . $whereLog);
	
		return $count;
	
	}
87046
public function GetCount($Wheres = '') {
      $this->_BeforeGet();
      
      $this->SQL
         ->Select('*', 'count', 'Count')
         ->From($this->Name);

      if (is_array($Wheres))
         $this->SQL->Where($Wheres);

      $Data = $this->SQL
         ->Get()
         ->FirstRow();

      return $Data === FALSE ? 0 : $Data->Count;
   }
126504
public function deleteTranslations($locales = null)
    {
        if ($locales === null) {
            $translations = $this->translations()->get();
        } else {
            $locales = (array) $locales;
            $translations = $this->translations()->whereIn($this->getLocaleKey(), $locales)->get();
        }
        foreach ($translations as $translation) {
            $translation->delete();
        }
        // we need to manually "reload" the collection built from the relationship
        // otherwise $this->translations()->get() would NOT be the same as $this->translations
        $this->load('translations');
    }
406257
protected function translate(array $filters, array $sorting = [], array $joins = [])
    {
        $constraints = [];

        foreach ($filters as $index => $filter) {
            if (array_key_exists('column', $filter) && array_key_exists('value', $filter)) {
                $constraints[] = $this->translateCriteria($filter, $joins);
                continue;
            }

            list($constraint, $sorting, $joins) = $this->translate($filter, $sorting, $joins);

            $this->translateOperation($index, $constraint, $constraints);
        }

        return [$constraints, $sorting, $joins];
    }