Method |
Description |
|
create ( array $data = [] ) : Row |
Create Row instance |
|
delete ( array $where ) : integer |
Deletes existing rows |
|
fetch ( string $sql, array $params = [] ) : array |
Fetching rows by SQL query |
|
fetchAll ( ) : array |
Fetch all rows from table
Be carefully with this method, can be very slow |
|
filterColumns ( array $data ) : array |
Filter columns for insert/update queries by table columns definition |
|
find ( $keys ) : array |
Fetches rows by primary key. The argument specifies one or more primary
key value(s). To find multiple rows by primary key, the argument must
be an array. |
|
findRow ( mixed $primaryKey ) : Row |
Find row by primary key |
|
findRowWhere ( array $whereList ) : Row |
Find row by where condition |
|
findWhere ( $where ) : array |
Find rows by WHERE
WHERE alias = 'foo'
Table::findWhere(['alias'=>'foo']);
WHERE alias = 'foo' OR 'alias' = 'bar'
Table::findWhere(['alias'=>'foo'], ['alias'=>'bar']);
WHERE (alias = 'foo' AND userId = 2) OR ('alias' = 'bar' AND userId = 4)
Table::findWhere(['alias'=>'foo', 'userId'=> 2], ['alias'=>'foo', 'userId'=>4]);
WHERE alias IN ('foo', 'bar')
Table::findWhere(['alias'=> ['foo', 'bar']]); |
|
getColumns ( ) : array |
Return information about tables columns |
|
getInstance ( ) : static |
Get Table instance |
|
getModel ( ) : string |
Get model name |
|
getName ( ) : string |
Get table name |
|
getPrimaryKey ( ) : array |
Get primary key(s) |
|
getSelectQuery ( ) : string |
Get select query |
|
init ( ) |
Initialization hook. |
|
insert ( array $data ) : string | null |
Insert new record to table and return last insert Id |
|
linkTo ( string $key, string $model, string $foreign ) : void |
Setup relation "one to one" or "one to many" |
|
linkToMany ( string $model, string $link ) : void |
Setup relation "many to many"
[table1-key] [table1_key-table2-table3_key] [table3-key] |
|
select ( ) : Select |
Prepare Db\Query\Select for current table:
- predefine "select" section as "*" from current table
- predefine "from" section as current table name and first letter as alias
- predefine fetch type |
|
setSelectQuery ( string $select ) : Table |
Set select query |
|
update ( array $data, array $where ) : integer |
Updates existing rows |
|