PHP Class WPDKDBTable

Deprecation: Since 0.6.2 - In working - Used yet by SmartShop
Author: =undo= ([email protected])
Datei anzeigen Open project: wpxtreme/wpdk

Public Methods

Method Description
arrayStatusesForSDF ( array $statuses ) : array Restituisce un array in formato SDF
cache ( string $table_name, integer $id, stdClass $record = null ) : stdClass | null Legge o imposta un transient/cache.
count ( string $table_name ) : integer Restituisce il numero di record della tabella
create ( string $table_name, array $values ) : mixed Crea, inserisce, un record in tabella
delete ( string $table_name, integer | array $record, string $id_field = 'id' ) : mixed Elimina uno o più record a partire sempre dall'id
record ( string $table_name, integer | object | array $record, string $id_field = 'id', string $output = OBJECT ) : boolean Estrae un singolo record
records ( string $table_name, string $where, string $order_by = '', string $output = OBJECT ) : mixed Estrae un insieme di record
slug ( $table_name )
status ( string $table_name, integer $record, string $id_field = 'id', string $field_name = 'post_status' ) : mixed Legge lo stato attuale di un record. Lo status è per default nel campo 'post_status' se presente.
statusesWithCount ( string $table_name, array $statuses, string $field_name = 'status' ) : array Restituisce un array con il tipo di status, la sua label e la count sul database
trash ( string $table_name, integer | array $record, string $id_field = 'id', string $field_name = 'post_status', string $value = 'trash' ) : mixed Imposta lo stato di uno o più record a 'trash' e memorizza lo stato attuale nella post meta con chiave '_[table name]_status'
untrash ( string $table_name, integer | array $record, string $id_field = 'id', string $field_name = 'post_status' ) : boolean Repristina uno o più record dal cestino recuperando lo stato precedente dalla chiave ''_[table name]_status' nella post meta. Se non la trova pone il record in status 'unknown'
update ( string $table_name, integer | object | array $record, array $values, string $id_field = 'id', array $formats = [] ) : mixed Esegue l'update di un record
where ( string | array $where, string $glue = 'AND' ) : string Prepara una condizione di WHERE partendo da un semplice stringa o da un Key value pairs campo/valore. Se il valore non è una stringa la condizione è campo = valore. Se il valore è una stringa la condizione è campo = 'valore'.

Method Details

arrayStatusesForSDF() public method

Restituisce un array in formato SDF
public arrayStatusesForSDF ( array $statuses ) : array
$statuses array
return array

cache() public method

Questa verrà aggiornata ogni qualvolta viene inserito, modificato o cancellato un post.
public cache ( string $table_name, integer $id, stdClass $record = null ) : stdClass | null
$table_name string
$id integer ID del post
$record stdClass Oggetto record dal database. Passare questo parametro per memorizzarlo in cache.
return stdClass | null Restituisce un oggetto di tipo stdClass o null se errore

count() static public method

Restituisce il numero di record della tabella
static public count ( string $table_name ) : integer
$table_name string
return integer

create() static public method

Crea, inserisce, un record in tabella
static public create ( string $table_name, array $values ) : mixed
$table_name string Nome della tabella
$values array Elenco Key value pairs, nome campo/valore
return mixed

delete() static public method

Elimina uno o più record a partire sempre dall'id
static public delete ( string $table_name, integer | array $record, string $id_field = 'id' ) : mixed
$table_name string
$record integer | array Singolo ID o array di ID da elimininare
$id_field string
return mixed

record() public method

Estrae un singolo record
public record ( string $table_name, integer | object | array $record, string $id_field = 'id', string $output = OBJECT ) : boolean
$table_name string
$record integer | object | array
$id_field string
$output string
return boolean

records() public method

Estrae un insieme di record
public records ( string $table_name, string $where, string $order_by = '', string $output = OBJECT ) : mixed
$table_name string
$where string
$order_by string
$output string
return mixed

slug() public method

public slug ( $table_name )

status() public method

Legge lo stato attuale di un record. Lo status è per default nel campo 'post_status' se presente.
public status ( string $table_name, integer $record, string $id_field = 'id', string $field_name = 'post_status' ) : mixed
$table_name string
$record integer
$id_field string
$field_name string
return mixed

statusesWithCount() public method

Restituisce un array con il tipo di status, la sua label e la count sul database
public statusesWithCount ( string $table_name, array $statuses, string $field_name = 'status' ) : array
$table_name string
$statuses array
$field_name string
return array Restituisce un array con il tipo di status, la sua label e la count sul database

trash() public method

Imposta lo stato di uno o più record a 'trash' e memorizza lo stato attuale nella post meta con chiave '_[table name]_status'
public trash ( string $table_name, integer | array $record, string $id_field = 'id', string $field_name = 'post_status', string $value = 'trash' ) : mixed
$table_name string
$record integer | array
$id_field string
$field_name string
$value string
return mixed

untrash() public method

Repristina uno o più record dal cestino recuperando lo stato precedente dalla chiave ''_[table name]_status' nella post meta. Se non la trova pone il record in status 'unknown'
public untrash ( string $table_name, integer | array $record, string $id_field = 'id', string $field_name = 'post_status' ) : boolean
$table_name string
$record integer | array
$id_field string
$field_name string
return boolean

update() static public method

Esegue l'update di un record
static public update ( string $table_name, integer | object | array $record, array $values, string $id_field = 'id', array $formats = [] ) : mixed
$table_name string
$record integer | object | array
$values array
$id_field string
$formats array
return mixed

where() static public method

Le condizioni sono per defaul in AND, altrimenti passando $glue = 'OR' si modifica il legame.
static public where ( string | array $where, string $glue = 'AND' ) : string
$where string | array
$glue string Default AND
return string