PHP Класс __WPDKDBTable

## Overview This class describe a database table. For default describe the table and gets the primary key name. This primary key is used for operations as delete one or more records.
Устаревший: since 1.5.1 - Use WPDKDBTableModel instead
Автор: =undo= ([email protected])
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$primaryKey string Name of field as primary key
$sqlFilename string The filename of SQL file with the database table structure and init data.
$tableName string The name of the database table with the WordPress prefix

Открытые методы

Метод Описание
__construct ( string $table_name, string $sql_file = '' ) Create an instance of __WPDKDBTable class
_select ( object $query = null, string $order_by = '', string $order = 'ASC' ) : array Return an array key-value with key as primary key of records.
count ( string $distinct = '', array $status = '' ) : integer | array Return the integer count of all rows when $distinct param is emmpty or an array of distinct count for $distinct column.
delete ( integer | array $pks ) : integer | boolean Delete one or more record from table. Return the number of rows affected/selected or false on error.
deleteWherePrimaryKey ( $id )
groupBy ( string $column, boolean $order_by = true, string $order = 'ASC' ) : array Return a column select group by and sorter
map ( object $source_row, object $destination_object ) : object | boolean Map the properties fields of single database row into a destination object model.
primaryKey ( ) : string Return the name of the primary key
select ( integer $id = false, $order_by = '', $order = 'ASC', $where = '' ) : object | array Return a single instance of $object class or an array of $object class. FALSE otherwise.
selectWhereID ( $id, $object, $output = OBJECT )
update ( ) : boolean Do an update the table via WordPress dbDelta() function. Apply a new SQL file on the exists (or do not exists) table. Return TRUE on success
where ( WPDKDBTableRow $query, string $prefix = '' ) : string Return the WHERE condiction string from a object

Описание методов

__construct() публичный Метод

Create an instance of __WPDKDBTable class
public __construct ( string $table_name, string $sql_file = '' )
$table_name string The name of the database table without WordPress prefix
$sql_file string Optional. The filename of SQL file with the database table structure and init data.

_select() публичный Метод

Return an array key-value with key as primary key of records.
public _select ( object $query = null, string $order_by = '', string $order = 'ASC' ) : array
$query object Optional. $query An object used for build the where. Usualy a subclass of WPDKDBTableRow
$order_by string Optional. Order by column name
$order string Optional. Order. Default ASC
Результат array

count() публичный Метод

Return the integer count of all rows when $distinct param is emmpty or an array of distinct count for $distinct column.
public count ( string $distinct = '', array $status = '' ) : integer | array
$distinct string Optional. Name of field to distinct group by
$status array Optional. Key value paier for where condiction on field: key = fields, vallue = value
Результат integer | array

delete() публичный Метод

Use the primaryKey.
public delete ( integer | array $pks ) : integer | boolean
$pks integer | array Any single int or array list of primary keys
Результат integer | boolean

deleteWherePrimaryKey() публичный Метод

Устаревший: Use delete() instead
public deleteWherePrimaryKey ( $id )

groupBy() публичный Метод

Return a column select group by and sorter
public groupBy ( string $column, boolean $order_by = true, string $order = 'ASC' ) : array
$column string name of column
$order_by boolean Optional. Order for column. Defaul TRUE
$order string Optional. Type of sorter. Default 'ASC'
Результат array

map() публичный Метод

The $destination_object can implement a method named column_[property] to override map process.
public map ( object $source_row, object $destination_object ) : object | boolean
$source_row object Database record
$destination_object object Object to map
Результат object | boolean The destination object with new properties or FALSE if error.

primaryKey() публичный Метод

Return the name of the primary key
public primaryKey ( ) : string
Результат string

select() публичный Метод

If select more rows as array, the OBJECT_K flag is used. In this way you have the key array equal to id of the country
Устаревший: Use _select() instead
public select ( integer $id = false, $order_by = '', $order = 'ASC', $where = '' ) : object | array
$id integer ID of record or array of id
Результат object | array

selectWhereID() публичный Метод

Устаревший: Use select() instead
public selectWhereID ( $id, $object, $output = OBJECT )

update() публичный Метод

Do an update the table via WordPress dbDelta() function. Apply a new SQL file on the exists (or do not exists) table. Return TRUE on success
public update ( ) : boolean
Результат boolean

where() публичный Метод

Return the WHERE condiction string from a object
public where ( WPDKDBTableRow $query, string $prefix = '' ) : string
$query WPDKDBTableRow An instance of WPDKDBTableRow
$prefix string Optional. Table prefix.
Результат string

Описание свойств

$primaryKey публичное свойство

Name of field as primary key
public string $primaryKey
Результат string

$sqlFilename публичное свойство

The filename of SQL file with the database table structure and init data.
public string $sqlFilename
Результат string

$tableName публичное свойство

The name of the database table with the WordPress prefix
public string $tableName
Результат string