public function pluck(string $column, string $keyBy = ''): array
    {
        $pdoStatement = $this->provideStatement();
        $pdoStatement = $this->execute($pdoStatement);
        $rows = $pdoStatement->fetchAll(\PDO::FETCH_ASSOC);
        if (empty($rows)) {
            return [];
        }
        if (!isset($rows[0][$column])) {
            throw new DatabaseException('Column not found in result.');
        }
        if (!empty($keyBy) && !isset($rows[0][$keyBy])) {
            throw new DatabaseException('Column to use as key not found in result.');
        }
        $indexKey = (!empty($keyBy)) ? $keyBy : null;
        return array_column($rows, $column, $indexKey);
    }
public function pluck(string $column, string $keyBy = ''): array
    {
        $pdoStatement = $this->provideStatement();
        $pdoStatement = $this->execute($pdoStatement);
        $rows = $pdoStatement->fetchAll(\PDO::FETCH_ASSOC);
        if (empty($rows)) {
            return [];
        }
        if (!isset($rows[0][$column])) {
            throw new DatabaseException('Column not found in result.');
        }
        if (!empty($keyBy) && !isset($rows[0][$keyBy])) {
            throw new DatabaseException('Column to use as key not found in result.');
        }
        $indexKey = (!empty($keyBy)) ? $keyBy : null;
        return array_column($rows, $column, $indexKey);
    }
public function pluck ( string $ column , string $ keyBy = '' ) : array { $ pdoStatement = $ this -> provideStatement ( ) ; $ pdoStatement = $ this -> execute ( $ pdoStatement ) ; $ rows = $ pdoStatement -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; if ( empty ( $ rows ) ) { return [ ] ; } if ( ! isset ( $ rows [ 0 ] [ $ column ] ) ) { throw new DatabaseException ( 'Column not found in result.' ) ; } if ( ! empty ( $ keyBy ) && ! isset ( $ rows [ 0 ] [ $ keyBy ] ) ) { throw new DatabaseException ( 'Column to use as key not found in result.' ) ; } $ indexKey = ( ! empty ( $ keyBy ) ) ? $ keyBy : null ; return array_column ( $ rows , $ column , $ indexKey ) ; }
Executes a select query and returns values of a single column. Optionally a custom key column can be specified.

@param string $column
@param string $keyBy
@return array
@throws DatabaseException
Executes a select query and returns values of a single column . Optionally a custom key column can be specified .