Returns the number of LTI tools.

@param array $params The list of SQL params (eg. array('columnname' => value, 'columnname2' => value)).
@return int The number of tools
554287
public static function count_lti_tools($params = array()) {
        global $DB;

        $sql = "SELECT COUNT(*)
                  FROM {enrol_lti_tools} elt
                  JOIN {enrol} e
                    ON elt.enrolid = e.id";
        if ($params) {
            $where = "WHERE";
            foreach ($params as $colname => $value) {
                $sql .= " $where $colname = :$colname";
                $where = "AND";
            }
        }

        return $DB->count_records_sql($sql, $params);
    }
1370138
public function get_events_select_count($selectwhere, array $params) {
        if (!$this->init()) {
            return 0;
        }

        if (!$dbtable = $this->get_config('dbtable')) {
            return 0;
        }

        return $this->extdb->count_records_select($dbtable, $selectwhere, $params);
    }
1040986
public function count($query, array $params = [])
    {
        $stmt = $this->connection->prepare($query);
        $stmt->execute($params);
        return $stmt->fetchColumn();
    }
48342
public function getNbEvenementsInHistorique($params = array())
    {
        $retour=0;
        if (isset($params['idEvenement'])) {
        //debug("A modifier vis  a vis de l'historique  (en principe la requete est ok");
            $req = "SELECT count(idHistoriqueEvenement) as nb FROM historiqueEvenement WHERE idEvenement=".$params['idEvenement'];
            $res = $this->connexionBdd->requete($req);
            $fetch = mysql_fetch_assoc($res);
            $retour = $fetch['nb'];
        }

        return $retour;
    }
506626
protected function count_button_rows(array &$params) {
        $maxrow = 1;
        foreach ($params as $key => $value) {
            if (preg_match('/^theme_advanced_buttons(\d+)$/', $key, $matches) &&
                    (int)$matches[1] > $maxrow) {
                $maxrow = (int)$matches[1];
            }
        }
        return $maxrow;
    }
1265397
protected function getColumnIndex($params)
    {
        if (isset($params['parent'])) {
            if (is_array($params['parent']) && isset($params['parent']['parent'])) {
                return md5($params['parent'][0]);
            }

            return md5($params['parent'], true);
        }

        return ++$this->iThead;
    }
861297
public function getDernieresActualites($params = array())
	{
		$sqlLimit = "";
		if (isset($params['sqlLimit']) && $params['sqlLimit']!='') {
			$sqlLimit = $params['sqlLimit'];

		}

		$sqlFields = "idActualite,  titre,  date,  ".
				"photoIllustration,  texte,  urlFichier";
		if (isset($params['sqlFields']) && $params['sqlFields']!='') {
			$sqlFields = $params['sqlFields'];
		}

		$sqlWhere = "";
		if (isset($params['sqlWhere']) && $params['sqlWhere']!='') {
			$sqlWhere = $params['sqlWhere'];
		}

		$req = "SELECT $sqlFields FROM actualites ".
				"WHERE 1=1 $sqlWhere ORDER BY date DESC $sqlLimit";
		$res = $this->connexionBdd->requete($req);

		$i=0;
		if (!isset($params['returnAsMysqlRes'])
		|| $params['returnAsMysqlRes']!=true
		) {
			$retour = array();
			while ($fetch = mysql_fetch_assoc($res)) {
				$retour[$i] = $fetch;
				$i++;
			}
		} else {
			$retour = $res;
		}

		return $retour;
	}
650653
protected function queryModify(string $sql, array $params = [], array $options = []): int {
        $options += [Db::OPTION_FETCH_MODE => 0];
        $stm = $this->query($sql, $params, $options);
        return $stm->rowCount();
    }
10417
public function getCount($where = [], $joinConditions = [], $prefix = 'u')
    {
        return $this->find($where, $prefix, true, $joinConditions);
    }
1247133
public function queryRow($params = [])
    {
        $this->setLimit(1);
        return $this->getDb()
            ->createCommand()
            ->setText($this->buildSql())
            ->queryRow(array_merge($this->getParams(), $params));
    }
690804
private function filterParameters(array $params): array
    {
        return
            array_filter(
                $params,
                function (&$value) {
                    if (is_array($value)) {
                        $value = $this->filterParameters($value);

                        return count($value) > 0;
                    } else {
                        return !is_null($value);
                    }
                }
            );
    }
418784
public function queryRow($params = array())
    {
        $this->mergeParams($params);
        $this->beginQuery();
        $rst = $this->statement->fetch(\PDO::FETCH_ASSOC);
        $this->statement->closeCursor();
        return $rst;
    }
209581
public static function _count ($params = array (), &$db = FALSE)
	{
		
		// Remove order

		if (isset ($params['orderby']))
		{
			unset ($params['orderby']);
		}
		
		// Remove limit

		if (isset ($params['limit']))
		{
			unset ($params['limit']);
		}

		// Select count

		$params['select'] = 'COUNT(*)';
		
		// Return
		
		return static::_getValue ($params, \PDO::FETCH_ASSOC, $db);

	}
794021
protected function _constructPdoDsn(array $params)
    {
        $dsn = 'sqlite:';
        if (isset($params['path'])) {
            $dsn .= $params['path'];
        } elseif (isset($params['memory'])) {
            $dsn .= ':memory:';
        }

        return $dsn;
    }
655342
protected function _getProductListSizeByParam( array $params )
	{
		/** client/html/catalog/list/size
		 * The number of products shown in a list page
		 *
		 * Limits the number of products that is shown in the list pages to the
		 * given value. If more products are available, the products are split
		 * into bunches which will be shown on their own list page. The user is
		 * able to move to the next page (or previous one if it's not the first)
		 * to display the next (or previous) products.
		 *
		 * The value must be an integer number from 1 to 100. Negative values as
		 * well as values above 100 are not allowed. The value can be overwritten
		 * per request if the "l-size" parameter is part of the URL.
		 *
		 * @param integer Number of products
		 * @since 2014.03
		 * @category User
		 * @category Developer
		 * @see client/html/catalog/list/catid-default
		 * @see client/html/catalog/list/domains
		 */
		$defaultSize = $this->_getContext()->getConfig()->get( 'client/html/catalog/list/size', 48 );

		$size = ( isset( $params['l-size'] ) ? (int) $params['l-size'] : $defaultSize );
		return ( $size < 1 || $size > 100 ? $defaultSize : $size );
	}
1325351
public function getPaginator($params) 
	{
        $limit = isset($params['limit']) ? (int) $params['limit'] : 10;
        $offset = isset($params['offset']) ? (int) $params['offset'] : 0;
        
        // @todo (re)setting limit and offset, make it better...
        $params['limit'] = $limit;
        $params['offset'] = $offset;
		
		// must check for limit
		//$page = isset($params['page']) ? (int)$params['page'] : 1;
		
		$fields = isset($params['field']) ? array_values($params['field']) : array();
		$values = isset($params['value']) ? array_values($params['value']) : array();
		
		$page = $params['offset'] / $params['limit'] + 1;
		$isLoggedUserSearch = false;
		$isFullSearch = false;
		$userId = '';
		foreach($fields as $key => $field) {
			switch($field) {
				case 'account':
					$isLoggedUserSearch = true;
					$userId = $values[$key];
					break;
			}
		}
		if($isLoggedUserSearch) {
			    //throw new \Exception('WIP hashid');
			$qb = $this->_em->createQueryBuilder();
			$qb->select(array('a'));
			$qb->from($this->getEntityName(), 'a');
			//$qb->andWhere($qb->expr()->eq('a.user', ':paramUserId'));
			$qb->andWhere($qb->expr()->eq('SHA1(CONCAT_WS(\'\', \'neo\', a.user, \'bazaar\'))', ':paramUserId'));
			$qb->andWhere($qb->expr()->eq('a.documentType', ':paramDocumentType'));
			$qb->andWhere($qb->expr()->neq('a.state', ':paramDocumentState'));
			$qb->setParameter('paramUserId', $userId);
			$qb->setParameter('paramDocumentType', Document::DOCUMENT_TYPE_CLASSIFIED);
			$qb->setParameter('paramDocumentState', Document::DOCUMENT_STATE_DELETED);
			//$qb->addOrderBy('COALESCE(a.dateEdit, a.dateInsert)', 'DESC');
			//$qb->addOrderBy('a.documentId', 'DESC');
			$qb->addOrderBy('a.dateEdit', 'DESC');
			$query = $qb->getQuery();
			$query->setFirstResult($params['offset']);
			$query->setMaxResults($params['limit']);
			$paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query));
			
			
// 			$paginator = new DoctrinePaginator($query, $fetchJoinCollection = true);
// 			$result = array();
// 			foreach($paginator as $p) {
// 				$result[] = $p->getDocumentId();
// 			}
// 			$result = $query->getResult();
// 			$paginatorAdapter =  new RazorPaginator(
// 				$result,
// 				count($paginator)
// 			);
		} else {
			$query = $this->fetchGridData($params);
			$query->setFirstResult(0);
			$query->setMaxResults($params['limit']);
			$paginatorAdapter =  new RazorArrayAdapter(
				$query->getResult(),
				$this->getSphinxClient()->getLastSearchCount()
			);
			//$paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query));
		}
		
		
		$paginator = new Paginator($paginatorAdapter);
		$paginator->setCurrentPageNumber($page);
		$paginator->setDefaultItemCountPerPage($params['limit']);
		
		return $paginator;
	}
348488
public function getNbResults($params = array())
    {

        if ( isset( $this->nbResults ) )
        {
            return $this->nbResults;
        }
        $this->nbResults = $this->handler->searchCount( $this->form, $this->criteriaBuilder, $params );
        return $this->nbResults;
    }