class DataSource implements IDataSource

Default implementation of IDataSource.

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(string|array $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)

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 $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 83
DataSource where($cond)

Adds conditions to query.

Parameters

$cond

Return Value

DataSource

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

Limits number of rows.

Parameters

int $limit
int $offset

Return Value

DataSource

at line 121
final Connection getConnection()

No description

Return Value

Connection

at line 133
Result getResult()

Returns (and queries) Result.

Return Value

Result

at line 142
ResultIterator getIterator()

No description

Return Value

ResultIterator

at line 151
Row|null fetch()

Generates, executes SQL query and fetches the single row.

Return Value

Row|null

at line 161
mixed fetchSingle()

Like fetch(), but returns only first field.

Return Value

mixed

value on success, null if no next record

at line 170
array fetchAll()

Fetches all records from table.

Return Value

array

at line 179
array fetchAssoc(string $assoc)

Fetches all records from table and returns associative tree.

Parameters

string $assoc

Return Value

array

at line 188
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 197
void release()

Discards the internal cache.

Return Value

void

at line 209
Fluent toFluent()

Returns this data source wrapped in Fluent object.

Return Value

Fluent

at line 218
DataSource toDataSource()

Returns this data source wrapped in DataSource object.

Return Value

DataSource

at line 227
string __toString()

Returns SQL query.

Return Value

string

at line 256
int count()

Returns the number of rows in a given data source.

Return Value

int

at line 272
int getTotalCount()

Returns the number of rows in a given data source.

Return Value

int

Traits

Better OOP experience.