get one

@param   string  $sql
@param   array   $params
@return  mixed
18591
public function getOne($sql, $params = [])
    {
        if ($sql instanceof Criteria\Criteria) return $this->getOne($sql->toSQL(), $sql->getParams());

        $sth = $this->query($sql, $params, Database::TARGET_SLAVE);
        $row = $sth->fetch(Connection::FETCH_NUM);
        $sth->closeCursor();
        return $row[0];
    }
1273079
public function execute($sql, $params = null)
    {
        $stmt = $this->_pdo->prepare($sql);

        if (is_array($params)) {
            foreach ($params as $token => $value) {
                $stmt->bindValue($token, $value);
            }
        }

        try {
            $stmt->execute();
        } catch (PDOException $exception) {
            $this->_database->error('execute', $exception);
        }

        return $stmt;
    }
743545
public function getRow($sql, $params = null)
    {
        $this->log('getRow', $sql, $params);

        return $this->_socket->getRow($sql, $params);
    }
1047025
protected function getSQLResultFromConnection($connection, $sql, array $params = array())
    {
        $result = $connection->fetchAll($sql, $params);
        return $result;
    }
719647
public function fetchValue($sql, array $parameters = [])
    {
        $statement = $this->executeQuery($sql, $parameters);

        return $statement->fetchColumn(0);
    }
925762
public function fetchColumn($sql, array $params = array(), $pos = 0)
    {
        return $this->run($sql, $params)->fetchColumn($pos);
    }
1080740
public function bind($sql, array $params=array())
    {
        return $this->_bindInto('\?', $sql, $params, function($binder, $param) use ($sql) {
            return $binder->sqlValue($param);
        });
    }
115072
public function count(string $sql, array $params = [])
    {
        $prepared = $this->prepare($sql, $params);
        $this->execute($prepared);
        $result = $prepared['statement']->rowCount();
        $prepared['statement']->closeCursor();
        return $result;
    }
1007927
public function getOne($sql, $params = array(), $column_number = 0)
    {
        $stmt = $this->execute($sql, $params);
        return $stmt->fetchColumn($column_number);
    }
52867
public function whereExistsRaw(string $sql, string ...$params)
    {
        $instance = $this->whereStrategyInstance();

        $instance->whereStrategy()->whereExistsRaw($sql, ...$params);

        return $instance;
    }
264582
public function sqlFetchAllColumn(string $sql, array $params = [], string $column = '0'): array
    {
        return $this->connection()->sqlFetchAllColumn($sql, $params, $column);
    }
970842
public function groupByRaw(string $sql, string ...$params)
    {
        $instance = $this->groupByStrategyInstance();

        $instance->groupByStrategy()->groupByRaw($sql, ...$params);

        return $instance;
    }
1177010
public function query($sql, array $params = array())
    {
        //$helper = $this->getHelper();
        $con = $this->establishConnection();
        $sth = $con->prepare($sql, array(Connection::ATTR_CURSOR => Connection::CURSOR_SCROLL));

        // bind params
        foreach($params as $key => $value){
            $type = Connection::PARAM_STR;
            if ( is_null($value) ) {
                $type = Connection::PARAM_NULL;
            } elseif ( is_int($value) ) {
                $type = Connection::PARAM_INT;
            } elseif ( is_bool($value) ) {
                $type = Connection::PARAM_BOOL;
            } elseif ( is_resource($value) ) {
                $type = Connection::PARAM_LOB;
            }
            if ( is_int($key) ) {
                $sth->bindValue($key + 1, $value, $type);
            } else {
                $sth->bindValue($key, $value, $type);
            }
        }

        $result = $sth->execute();
        return $sth;
    }
343621
public static function getSqlWithParams(string $sql, array $params = []): string
    {
        if (! empty($params)) {
            $indexed = ($params === array_values($params));
            foreach ($params as $k => $v) {
                if (is_string($v)) {
                    $v = "'${v}'";
                }
                if (is_array($v)) {
                    $v = "'" . implode("','", $v) . "'";
                }
                if ($indexed) {
                    $sql = preg_replace('/\?/', $v, $sql, 1);
                } else {
                    $sql = str_replace(":${k}", $v, $sql);
                }
            }
        }

        return str_replace(PHP_EOL, '', $sql);
    }
609085
public function getAllPosts($sql, $params)
    {
        $posts = $this->findAllWhere("$sql", $params);

        // array_reverse so latest order question gets returned
        return array_map(array($this, 'setupPost'), $posts);
    }
383077
public function getResultsAsObjects($sql, $params = null)
    {
        $stmt = $this->execute($sql, $params);

        return $stmt->fetchAll(PDO::FETCH_OBJ);
    }
1185988
protected function fetchAll( $sql, $params = null ) {
		$this->logger->debug( $sql, $params ?: [] );
		$stmt = $this->dbh->prepare( $sql );
		$this->bind( $stmt, $params );
		$stmt->execute();
		return $stmt->fetchAll();
	}