com\setasign\SetaFramework\Database

TableInterface Class TableInterface

File: /SetaFramework/src/Database/TableInterface.php

Implemented in

Summary

Methods

createRow()

abstract public TableInterface::createRow (
array $data = array ( )
): Table\Row

Creates a row object for this table instance (but doesn't save it)

Parameters
$data : array
 

delete()

abstract public TableInterface::delete (
string|callable $where
): void

Delete from the database table

Be careful with this method!! A wrong $where-condition can delete every row in the table.

If you use aliases for columns you can't use the alias in the where condition. You will have to use the real column name.

You can't filter for magical columns in this method!

$where can be an Closure. The Closure will be called with (Query\Delete $query, Database $db) and has no return. $query won't be inserted directly, only the added where-parts (where, whereOr, whereParentheseOpen, whereOrParentheseOpen, whereParenthesClose) will be used.

Parameters
$where : string|callable
 

find()

abstract public TableInterface::find (
int|string|array<string, mixed> $primaryKey,
?Table\Row $row = null
): ?Table\Row

Return a result of a database query fetched by primary key

Parameters
$primaryKey : int|string|array<string, mixed>
 
$row : ?Table\Row
 

getColumns()

abstract public TableInterface::getColumns (
void
): array

Return all column names of the table

getDb()

abstract public TableInterface::getDb (
void
): Database

Return the database instance

getHiddenColumns()

abstract public TableInterface::getHiddenColumns (
void
): array

Get all hidden columns which won't get exposed through the toArray() method of a table row

getMagicColumns()

abstract public TableInterface::getMagicColumns (
void
): array

Return all magic columns of the table

getPrimaryKey()

abstract public TableInterface::getPrimaryKey (
void
): array

Return the primary key of the table

getRowClassName()

abstract public TableInterface::getRowClassName (
void
): string

Get the row class name

getSelect()

abstract public TableInterface::getSelect (
void
): TableSelectInterface

insert()

abstract public TableInterface::insert (
array $data
): int

Insert a row into the table.

$data need to be an array, where the key is the column and the value is the new value. If an column of this array isn't defined in the table, this will skipped!

Parameters
$data : array
 
Return Values

Returns the last inserted id

update()

abstract public TableInterface::update (
array $data,
null|string|callable $where = null
): void

Updates one or more rows in the table.

Be careful with this method!! A wrong or missing $where-condition can edit every row in the table.

$data need to be an array, where the key is the column and the value is the new value. If an column of this array isn't defined in the table, this will skipped!

$where can be an Closure. The Closure will be called with (Query\Update $query, Database $db) and has no return. $query won't be inserted directly, only the added where-parts (where, whereOr, whereParentheseOpen, whereOrParentheseOpen, whereParenthesClose) will be used.

Parameters
$data : array
 
$where : null|string|callable