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 33
__construct(string $sql, Connection $connection)

No description

Parameters

string $sql

command or table or view name, as data source

Connection $connection

at line 47
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 63
DataSource where($cond)

Adds conditions to query.

Parameters

$cond

Return Value

DataSource

at line 77
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 93
DataSource applyLimit(int $limit, int|null $offset = null)

Limits number of rows.

Parameters

int $limit
int|null $offset

Return Value

DataSource

at line 102
final Connection getConnection()

No description

Return Value

Connection

at line 114
Result getResult()

Returns (and queries) Result.

Return Value

Result

at line 124
ResultIterator getIterator()

No description

Return Value

ResultIterator

at line 133
Row|null fetch()

Generates, executes SQL query and fetches the single row.

Return Value

Row|null

at line 143
mixed fetchSingle()

Like fetch(), but returns only first field.

Return Value

mixed

value on success, null if no next record

at line 152
array fetchAll()

Fetches all records from table.

Return Value

array

at line 161
array fetchAssoc(string $assoc)

Fetches all records from table and returns associative tree.

Parameters

string $assoc

Return Value

array

at line 170
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 179
void release()

Discards the internal cache.

Return Value

void

at line 191
Fluent toFluent()

Returns this data source wrapped in Fluent object.

Return Value

Fluent

at line 200
DataSource toDataSource()

Returns this data source wrapped in DataSource object.

Return Value

DataSource

at line 209
string __toString()

Returns SQL query.

Return Value

string

at line 233
int count()

Returns the number of rows in a given data source.

Return Value

int

at line 250
int getTotalCount()

Returns the number of rows in a given data source.

Return Value

int