class DataSource implements IDataSource

Default implementation of IDataSource.

Traits

Better OOP experience.

Methods

__construct(string $sql, Connection $connection)

No description

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

Selects columns to query.

where($cond)

Adds conditions to query.

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

Selects columns to order by.

applyLimit(int $limit, int $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 $key = null, string $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 54
__construct(string $sql, Connection $connection)

Parameters

string $sql
Connection $connection

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

Selects columns to query.

Parameters

string|array $col column name or array of column names
string $as column alias

Return Value

DataSource

at line 85
DataSource where($cond)

Adds conditions to query.

Parameters

$cond

Return Value

DataSource

at line 102
DataSource orderBy($row, string $direction = 'ASC')

Selects columns to order by.

Parameters

$row
string $direction

Return Value

DataSource

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

Limits number of rows.

Parameters

int $limit
int $offset

Return Value

DataSource

at line 126
final Connection getConnection()

Return Value

Connection

at line 138
Result getResult()

Returns (and queries) Result.

Return Value

Result

at line 147
ResultIterator getIterator()

Return Value

ResultIterator

at line 156
Row|null fetch()

Generates, executes SQL query and fetches the single row.

Return Value

Row|null

at line 166
mixed fetchSingle()

Like fetch(), but returns only first field.

Return Value

mixed value on success, null if no next record

at line 175
array fetchAll()

Fetches all records from table.

Return Value

array

at line 184
array fetchAssoc(string $assoc)

Fetches all records from table and returns associative tree.

Parameters

string $assoc

Return Value

array

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

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

Parameters

string $key
string $value

Return Value

array

at line 202
void release()

Discards the internal cache.

Return Value

void

at line 214
Fluent toFluent()

Returns this data source wrapped in Fluent object.

Return Value

Fluent

at line 223
DataSource toDataSource()

Returns this data source wrapped in DataSource object.

Return Value

DataSource

at line 232
string __toString()

Returns SQL query.

Return Value

string

at line 255
int count()

Returns the number of rows in a given data source.

Return Value

int

at line 271
int getTotalCount()

Returns the number of rows in a given data source.

Return Value

int