count() публичный Метод

Retrieves the amount of expressions on composite expression.
public count ( ) : integer
Результат integer
Пример #1
0
 /**
  * Gets a list of published entities as an array id => label
  *
  * @param CompositeExpression $expr        Use $factory->getDatabase()->getExpressionBuilder()->andX()
  * @param array               $parameters  Parameters used in $expr
  * @param string              $labelColumn Column that houses the label
  * @param string              $valueColumn Column that houses the value
  *
  * @return array
  */
 public function getSimpleList(CompositeExpression $expr = null, array $parameters = array(), $labelColumn = null, $valueColumn = 'id')
 {
     $q = $this->_em->getConnection()->createQueryBuilder();
     $alias = $prefix = $this->getTableAlias();
     if (!empty($prefix)) {
         $prefix .= '.';
     }
     $tableName = $this->_em->getClassMetadata($this->getEntityName())->getTableName();
     $class = '\\' . $this->getClassName();
     $reflection = new \ReflectionClass(new $class());
     // Get the label column if necessary
     if ($labelColumn == null) {
         if ($reflection->hasMethod('getTitle')) {
             $labelColumn = 'title';
         } else {
             $labelColumn = 'name';
         }
     }
     $q->select($prefix . $valueColumn . ' as value, ' . $prefix . $labelColumn . ' as label')->from($tableName, $alias)->orderBy($prefix . $labelColumn);
     if ($expr !== null && $expr->count()) {
         $q->where($expr);
     }
     if (!empty($parameters)) {
         $q->setParameters($parameters);
     }
     // Published only
     if ($reflection->hasMethod('getIsPublished')) {
         $q->andWhere($q->expr()->eq($prefix . 'is_published', ':true'))->setParameter('true', true, 'boolean');
     }
     return $q->execute()->fetchAll();
 }
Пример #2
0
 /**
  * Retrieves the amount of expressions on composite expression.
  *
  * @return integer
  */
 public function count()
 {
     return $this->compositeExpression->count();
 }