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

No description

Parameters

string $sql

command or table or view name, as data source

Connection $connection

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

Adds conditions to query.

Parameters

$cond

Return Value

DataSource

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

Limits number of rows.

Parameters

int $limit
int|null $offset

Return Value

DataSource

at line 123
final Connection getConnection()

No description

Return Value

Connection

at line 135
Result getResult()

Returns (and queries) Result.

Return Value

Result

at line 145
ResultIterator getIterator()

No description

Return Value

ResultIterator

at line 154
Row|null fetch()

Generates, executes SQL query and fetches the single row.

Return Value

Row|null

at line 164
mixed fetchSingle()

Like fetch(), but returns only first field.

Return Value

mixed

value on success, null if no next record

at line 173
array fetchAll()

Fetches all records from table.

Return Value

array

at line 182
array fetchAssoc(string $assoc)

Fetches all records from table and returns associative tree.

Parameters

string $assoc

Return Value

array

at line 191
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 200
void release()

Discards the internal cache.

Return Value

void

at line 212
Fluent toFluent()

Returns this data source wrapped in Fluent object.

Return Value

Fluent

at line 221
DataSource toDataSource()

Returns this data source wrapped in DataSource object.

Return Value

DataSource

at line 230
string __toString()

Returns SQL query.

Return Value

string

at line 259
int count()

Returns the number of rows in a given data source.

Return Value

int

at line 276
int getTotalCount()

Returns the number of rows in a given data source.

Return Value

int

Traits

Better OOP experience.