Exemplo n.º 1
0
    /**
     * @param  Fetcher $fetcher
     * @return int
     */
    public function getCountByFetcher(Fetcher $fetcher)
    {
        $query = $this->getQuery($fetcher);
        list($filterInReq, $filterToParameter) = $this->queryBuilder->buildFilters($fetcher);
        $sql = <<<SQL
SELECT
    count(DISTINCT id)
FROM
    ({$query}) as sub
WHERE
    {$filterInReq}
SQL;
        return $this->db->fetchOne($sql, $filterToParameter);
    }
Exemplo n.º 2
0
 /**
  * @param string $query
  * @param array  $parameters
  *
  * @return mixed
  */
 public function fetchOne($query, array $parameters = array())
 {
     $parameters = $this->parameterTransformer->transform($parameters);
     $this->stopWatch->start('query', 'database');
     $result = $this->reader->fetchOne($query, $parameters);
     $event = $this->stopWatch->stop('query');
     $this->log($query, $parameters, $event, 'fetch', 'one');
     return $result;
 }
Exemplo n.º 3
0
    /**
     * @param \Berthe\Fetcher $fetcher
     * @return \Berthe\Fetcher
     */
    public function selectCountByFetcher(\Berthe\Fetcher $fetcher)
    {
        list($filterInReq, $filterToParameter) = $this->queryBuilder->buildFilters($fetcher);
        $sql = <<<EOL
SELECT
    count({$this->getIdentityColumn()})
FROM
    {$this->getTableName()}
WHERE
    {$this->addAutoFilterSql($filterInReq)}
EOL;
        return $this->db->fetchOne($sql, $filterToParameter);
    }
Exemplo n.º 4
0
    public function invert($value, $lang)
    {
        $sql = <<<SQL
SELECT
    key
FROM
    translations_engine
WHERE
    value = ?
    AND lang = ?
SQL;
        $key = $this->reader->fetchOne($sql, array($value, $lang));
        if ($key) {
            return $key;
        } else {
            return false;
        }
    }