class DataSource implements IDataSource

Default implementation of IDataSource.

Methods

__construct(string $sql, Connection $connection)

No description

select(string|array $col, string|null $as = null)

Selects columns to query.

where($cond)

Adds conditions to query.

orderBy(string|array $row, string $direction = 'ASC')

Selects columns to order by.

applyLimit(int $limit, int|null $offset = null)

Limits number of rows.

getConnection()

No description

getResult()

Returns (and queries) Result.

getIterator()

No description

Row|null
fetch()

Generates, executes SQL query and fetches the single row.

mixed
fetchSingle()

Like fetch(), but returns only first field.

array
fetchAll()

Fetches all records from table.

array
fetchAssoc(string $assoc)

Fetches all records from table and returns associative tree.

array
fetchPairs(string|null $key = null, string|null $value = null)

Fetches all records from table like $key => $value pairs.

void
release()

Discards the internal cache.

toFluent()

Returns this data source wrapped in Fluent object.

toDataSource()

Returns this data source wrapped in DataSource object.

string
__toString()

Returns SQL query.

int
count()

Returns the number of rows in a given data source.

int
getTotalCount()

Returns the number of rows in a given data source.

Details

at line 44
__construct(string $sql, Connection $connection)

No description

Parameters

string $sql

command or table or view name, as data source

Connection $connection

at line 58
DataSource select(string|array $col, string|null $as = null)

Selects columns to query.

Parameters

string|array $col

column name or array of column names

string|null $as

column alias

Return Value

DataSource

at line 74
DataSource where($cond)

Adds conditions to query.

Parameters

$cond

Return Value

DataSource

at line 88
DataSource orderBy(string|array $row, string $direction = 'ASC')

Selects columns to order by.

Parameters

string|array $row

column name or array of column names

string $direction

Return Value

DataSource

at line 104
DataSource applyLimit(int $limit, int|null $offset = null)

Limits number of rows.

Parameters

int $limit
int|null $offset

Return Value

DataSource

at line 113
final Connection getConnection()

No description

Return Value

Connection

at line 125
Result getResult()

Returns (and queries) Result.

Return Value

Result

at line 135
ResultIterator getIterator()

No description

Return Value

ResultIterator

at line 144
Row|null fetch()

Generates, executes SQL query and fetches the single row.

Return Value

Row|null

at line 154
mixed fetchSingle()

Like fetch(), but returns only first field.

Return Value

mixed

value on success, null if no next record

at line 163
array fetchAll()

Fetches all records from table.

Return Value

array

at line 172
array fetchAssoc(string $assoc)

Fetches all records from table and returns associative tree.

Parameters

string $assoc

Return Value

array

at line 181
array fetchPairs(string|null $key = null, string|null $value = null)

Fetches all records from table like $key => $value pairs.

Parameters

string|null $key
string|null $value

Return Value

array

at line 190
void release()

Discards the internal cache.

Return Value

void

at line 202
Fluent toFluent()

Returns this data source wrapped in Fluent object.

Return Value

Fluent

at line 211
DataSource toDataSource()

Returns this data source wrapped in DataSource object.

Return Value

DataSource

at line 220
string __toString()

Returns SQL query.

Return Value

string

at line 244
int count()

Returns the number of rows in a given data source.

Return Value

int

at line 261
int getTotalCount()

Returns the number of rows in a given data source.

Return Value

int

Traits

Better OOP experience.