PHP 클래스 WPDKDBTableModel

If you would like use this model in a list table view controller, see the interface of WPDKListTableModel.
저자: =undo= ([email protected])
파일 보기 프로젝트 열기: wpxtreme/wpdk 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$crud_results boolean Used for check the CRUD action results
$primary_key string Name of field as primary key
$sql_filename string The filename of SQL file with the database table structure and init data.
$table_name string The name of the database table with the WordPress prefix

공개 메소드들

메소드 설명
__construct ( string $table_name, string $sql_file = '', string $primary_key = 'id' ) : WPDKDBTableModel Create an instance of WPDKDBTableModel class
delete ( integer | array $id ) : integer | boolean Delete one or more record from table. Return the number of rows affected/selected or WP_Error.
group_by ( string $column, string $order = 'ASC' ) : mixed Return a list of groupped by column. Use 'value' as selector
insert ( ) : integer | WP_Error Insert a record by values and return the id on successfull, otherwise return WP_Error.
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 ( ) Select data
update ( ) : integer | WP_Error Update a record by values and retrun TRUE onsuccessfully, otherwise return a WP_Error.
update_table ( ) : 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 ( array $args, string $key, string $table_prefix = '', array $not_in = [], string $cond = '=' ) : string Return a where condiction with possible OR values
where_date ( array $args, string $column_key, string $table_prefix = '', string $accuracy = '%Y-%m-%d %H:%i:%s' ) : string Return a where condiction for date and date time
where_filter ( array $args, string $filter, string $key, string $table_prefix = '', array $not_in = [], string $cond = '=' ) : string Return a where condiction with possible OR values for a filter. Useful for JOIN table

메소드 상세

__construct() 공개 메소드

Create an instance of WPDKDBTableModel class
public __construct ( string $table_name, string $sql_file = '', string $primary_key = 'id' ) : WPDKDBTableModel
$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.
$primary_key string Optional. If FALSE the primary key is get from database.
리턴 WPDKDBTableModel

delete() 공개 메소드

Use the primaryKey. The delete result is store in $this->crud_results.
public delete ( integer | array $id ) : integer | boolean
$id integer | array Any single int or array list of primary keys
리턴 integer | boolean

group_by() 공개 메소드

$results = ::group_by( 'column' ); foreach( $results as $row ) echo $row->value;
public group_by ( string $column, string $order = 'ASC' ) : mixed
$column string Column name
$order string Optional. Order 'ASC' or 'DESC'
리턴 mixed

insert() 공개 메소드

The insert result is store in $this->crud_results.
public insert ( ) : integer | WP_Error
리턴 integer | WP_Error

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() 공개 메소드

Select data
public select ( )

update() 공개 메소드

The update result is store in $this->crud_results.
public update ( ) : integer | WP_Error
리턴 integer | WP_Error

update_table() 공개 메소드

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_table ( ) : boolean
리턴 boolean

where() 공개 정적인 메소드

$where[] = ::where( $args, self::COLUMN_STATUS, '', array( WPXSSCouponStatus::ALL ) ); If $args[self::COLUMN_STATUS] is an array ( status = 'pending' OR status = 'confirmed' ) If $args[self::COLUMN_STATUS] is a string ( status = 'pending' ) $where[] = ::where( $args, self::COLUMN_STATUS, 'coupon', array( WPXSSCouponStatus::ALL ) ); If $args[self::COLUMN_STATUS] is a string ( coupon.status = 'pending' )
public static where ( array $args, string $key, string $table_prefix = '', array $not_in = [], string $cond = '=' ) : string
$args array Arguments list
$key string A key selector
$table_prefix string Optional. Table prefix
$not_in array Optional. Value to exclude
$cond string Optional. Condiction used, default '=' or 'LIKE'
리턴 string

where_date() 공개 정적인 메소드

$where[] = ::where_date( $args, self::COLUMN_DATE ); If $args[self::COLUMN_DATE] is a string ( DATE_FORMAT( col_date, '%Y-%m-%d %H:%i:%s' ) = '2014-01-01' ) If $args[self::COLUMN_DATE] is an array( '2014-01-01', '2014-02-01' ) ( DATE_FORMAT( col_date, '%Y-%m-%d %H:%i:%s' ) >= '2014-01-01' ) AND DATE_FORMAT( col_date, '%Y-%m-%d %H:%i:%s' ) <= '2014-02-01' ) )
public static where_date ( array $args, string $column_key, string $table_prefix = '', string $accuracy = '%Y-%m-%d %H:%i:%s' ) : string
$args array Arguments list
$column_key string Name of column
$table_prefix string Optional. Table prefix
$accuracy string Optional. Default = '%Y-%m-%d %H:%i:%s'
리턴 string

where_filter() 공개 정적인 메소드

$where[] = ::where( $args, self::FILTER_USER_ID, 'ID', 'users' ); ( users.ID = '34' )
public static where_filter ( array $args, string $filter, string $key, string $table_prefix = '', array $not_in = [], string $cond = '=' ) : string
$args array Arguments list
$filter string A key for filter
$key string A key selector
$table_prefix string Optional. Table prefix
$not_in array Optional. Value to exclude
$cond string Optional. Condiction used, default '=' or 'LIKE'
리턴 string

프로퍼티 상세

$crud_results 공개적으로 프로퍼티

Used for check the CRUD action results
public bool $crud_results
리턴 boolean

$primary_key 공개적으로 프로퍼티

Name of field as primary key
public string $primary_key
리턴 string

$sql_filename 공개적으로 프로퍼티

The filename of SQL file with the database table structure and init data.
public string $sql_filename
리턴 string

$table_name 공개적으로 프로퍼티

The name of the database table with the WordPress prefix
public string $table_name
리턴 string