\LtDbTableDataGateway

Database Table abstract

Summary

Methods
Properties
Constants
count()
delete()
deleteRows()
fetch()
fetchRows()
insert()
update()
updateRows()
$configHandle
$dbh
$createdColumn
$modifiedColumn
$tableName
No constants found
buildFieldList()
$fields
$primaryKey
$servers
N/A
No private methods found
No private properties found
N/A

Properties

$configHandle

$configHandle

$dbh

$dbh

$createdColumn

$createdColumn : string

The created field name

Type

string

$modifiedColumn

$modifiedColumn : string

The modified field name

Type

string

$tableName

$tableName : string

The table name

Type

string

$fields

$fields : array

The fields array

Type

array

$primaryKey

$primaryKey : string

The primary key

Type

string

$servers

$servers

Methods

count()

count(array  $args = null) : int

A shortcut to SELECT COUNT(*) FROM table WHERE condition

Parameters

array $args

Returns

int —

Examples

count(array('expression' => 'id < :id', 'value' => array('id' => 10)));

                                                

delete()

delete(string  $primaryKeyId) : string

Delete a row by primary key

Parameters

string $primaryKeyId

Returns

string —

Examples

delete(10);

                                                

deleteRows()

deleteRows(array  $args = null) : int

Delete many rows from table Please use this method carefully!

Parameters

array $args

Returns

int —

Examples

deleteRows(array('expression' => "id > :id", 'value' => array('id' => 2)));

                                                

fetch()

fetch(string  $primaryKeyId, array  $args = null, bool  $useSlave = true) : array

Fetch one row from table by primary key

Parameters

string $primaryKeyId
array $args
bool $useSlave

Returns

array —

Examples

fetch(10)

                                                

fetchRows()

fetchRows(array  $args = null, bool  $useSlave = true) : array

Fetch many rows from table

Parameters

array $args
bool $useSlave

Returns

array —

Examples

fetchRows(array('where' => array('expression' => "id > :id", 'value' => array('id' => 2))));

                                                

insert()

insert(array  $args = null) : string

Insert one row into table, then return the inserted row's pk

Parameters

array $args

Returns

string —

Examples

insert(array('name' => 'lily', 'age' => '12'));

                                                

update()

update(string  $primaryKeyId, array  $args = null) : int

Update one row by primary key

Parameters

string $primaryKeyId
array $args

Returns

int —

Examples

update(1, array('name' => 'lily', 'age' => '18'));

                                                

updateRows()

updateRows(array  $where, array  $args = null) : int

Update manay rows Please use this method carefully!

Parameters

array $where
array $args

Returns

int —

Examples

updateRows(array('expression' => "id > :id", 'value' => array('id' => 2)), array('name' => 'kiwi', 'age' => '1'));

                                                

buildFieldList()

buildFieldList() : array

Build table's field list

Returns

array —