get cols

@param   string  $sql
@param   array   $params
@return  array
354816
public function getCol($sql, $params = [], $column = 0)
    {
        if ($sql instanceof Criteria\Criteria) return $this->getCol($sql->toSQL(), $sql->getParams(), $column);

        $sth = $this->query($sql, $params, Database::TARGET_SLAVE);
        $col = [];
        foreach ($sth->fetchAll(Connection::FETCH_BOTH) as $row) {
            $col[] = array_key_exists($column, $row) ? $row[$column] : null;
        }
        return $col;
    }
432604
protected function replaceParams($sql, array $params) {
		$i=0;
		return preg_replace_callback('/\?/', function() use(&$i, $params, $sql) {
			$rep = $params[$i++];
			if(!$rep instanceof Raw && !$rep instanceof static)
				return "'".addslashes($rep)."'";
			else
				return '?';
		}, $sql);
	}
143445
public function sql(string $sql, array $params = []) {
        $r = $this->model->db->query($sql, $params);
        if (!is_array($r) || 0 === count($r)) {
            return [];
        }
        return $this->model->setup($r);
    }
638950
public function unionRaw(string $sql, string ...$params)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->unionRaw($sql, ...$params);

        return $instance;
    }
1080740
public function bind($sql, array $params=array())
    {
        return $this->_bindInto('\?', $sql, $params, function($binder, $param) use ($sql) {
            return $binder->sqlValue($param);
        });
    }
1312102
public function sqlFetchColumn(string $sql, array $params = [], string $column = '0')
    {
        $stmt = $this->prepare($sql, $params);

        if (ctype_digit((string) $column)) {
            return $stmt->fetchColumn($column);
        }

        if ($record = $stmt->fetch()) {
            return array_key_exists($column, $record) ? $record[$column] : null;
        }

        return null;
    }
374873
public function fetch($sql, $params = array(), $types = array())
    {
        return $this->query($sql, $params, $types)->fetch();
    }
708432
public function sql(string $sql, array $params = array()) {
        X::logger()->trace('Redis cached sql');
        $key = $this->getSqlKey($sql, $params);
        /** @noinspection UnserializeExploitsInspection */
        $pks = @unserialize($this->redis()->get($key));
        if ($pks) {
            X::logger()->trace("Hit sql $key");
            return $this->pks2models($pks);
        }

        X::logger()->trace("Miss sql $key");
        return $this->manySet($key,
            DirectModelManager::getInstance($this->model)
                ->sql($sql, $params)
        );
    }
1277492
public function execute($sql, array $params=array())
	{
		if ($params) {
			$stmt = $this->prepare($sql);
			if (!$stmt) { return false; }

			$flag = $stmt->execute($params);
			if (!$flag) { return false; }
		} else {
			$stmt = $this->query($sql);
			if (!$stmt) { return false; }
		}

		return $stmt->rowCount();
	}
420754
public function sqlFetch(string $sql, array $params = []): ?array
    {
        return $this->prepare($sql, $params)->fetch(\PDO::FETCH_ASSOC);
    }
1321718
public function getAll($sql, $params = array())
    {
        $stmt = $this->execute($sql, $params);
        return $stmt->fetchAll($this->fetchMode);
    }
869364
public function fetchColumn($sql, array $params=null, $column=0)
	{
        $sql .= " LIMIT 1";

		if ($params) {
			$stmt = $this->prepare($sql);
			if (!$stmt) { return false; }

			$flag = $stmt->execute($params);
			if (!$flag) { return false; }
		} else {
			$stmt = $this->query($sql);
			if (!$stmt) { return false; }
		}

		return $stmt->fetchColumn($column);
	}
600382
public function whereNotExistsRaw(string $sql, string ...$params)
    {
        $instance = $this->whereStrategyInstance();

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

        return $instance;
    }
380950
public static function exec($sql, $params = [])
    {
        BLLog::log('[SQL] ' . $sql);
        BLLog::log('[Params] ' . var_export($params, true));
        $stmt = self::getHandle()->prepare($sql);
        $stmt->execute($params);
        return $stmt;
    }
383077
public function getResultsAsObjects($sql, $params = null)
    {
        $stmt = $this->execute($sql, $params);

        return $stmt->fetchAll(PDO::FETCH_OBJ);
    }
1126463
protected static function fetch($sql, $params = []): array
    {
        $self = static::getInstance();
        return DbProxy::fetchObjects($sql, $params, $self->rowClass);
    }
712433
public function fetchColumnAll($sql, array $params=null, $column=0, $offset=0, $length=0)
	{
        if ($length > 0) {
            $sql .= " LIMIT " . (int)$offset . ', '. (int)$length;
        }

		if ($params) {
			$stmt = $this->prepare($sql);
			if (!$stmt) { return false; }

			$flag = $stmt->execute($params);
			if (!$flag) { return false; }
		} else {
			$stmt = $this->query($sql);
			if (!$stmt) { return false; }
		}

		return $stmt->fetchAll(PDO::FETCH_COLUMN, $column);
	}