PHP Class Pix_Table, pixframework

ファイルを表示 Open project: pixnet/pixframework Class Usage Examples

Public Properties

Property Type Description
$_aliases _aliases 建立 relation 的 aliases
$_cache_groups 記錄哪些東西要 Cache
$_cache_rows
$_columns _columns 這個 Table 有哪些 column
$_force_master
$_hooks _hooks 這個 Table 有哪些 hook
$_indexes array _indexes 該 Table 用到的 index
$_log_groups 記錄哪些東西要 Log
$_name string _name 這個 Table 在 Db 上面的名稱是什麼
$_primary string | array _primary Primary key, 可以是
$_relations _relations 這個 Table 有哪些 relation
$_resultSetClass string _resultSetClass 這個 Table 的 ResultSet class
$_rowClass string _rowClass 這個 Table 的 Row class
$_save_memory
$_throw_incorrect_string_exception
$_verify

Protected Properties

Property Type Description
$_cache
$_class
$_db
$_default_db @codeCoverageIgnoreEnd
$_filters
$_helper_managers
$_index_datas
$_query_comment
$_static_helper_managers
$_table_cache
$_table_cache_prefix
$_table_pool

Public Methods

Method Description
__call ( $name, $args )
__callStatic ( $name, $args )
__construct ( )
addFilter ( $filter, $funcname = '' )
addIndex ( string $name, array $columns, string $type = 'index' ) : void addIndex 增加一組 INDEX
addResultSetHelper ( string $helper, array $methods = null, array $options = [] ) : void addResultSetHelper add ResultSet Helper to this Table
addRowHelper ( string $helper, array $methods = null, array $options = [] ) : void addRowHelper add Row Helper to this Table
addStaticResultSetHelper ( string $helper, array $methods = null, array $options = [] ) : void addStaticResultSetHelper add ResuletSet Helper to all Table
addStaticRowHelper ( string $helper, array $methods = null, array $options = [] ) : void addStaticRowHelper add Row Helper to all Table
addStaticTableHelper ( string $helper, array $methods = null, array $options = [] ) : void addStaticTableHelper add Table Helper to all Table
addTableHelper ( string $helper, array $methods = null, array $options = [] ) : void addTableHelper add Table Helper to this Table
bulkInsert ( array $keys, array $values_list, array $options = [] ) : void bulk insert
cacheRow ( array $primary_values, array $data ) : void cacheRow
checkTable ( ) : array checkTable 檢查 Table 與資料庫上的不同
createRow ( Pix_Table_Row | null $belong_row = null ) : Pix_Table_Row createRow 新增加一個未被存入資料庫內的 row
createTable ( ) : void createTable 在資料庫上建立新 Table
debug ( $word ) @codeCoverageIgnoreStart
disableCache ( mixed $group ) : void disableCache 關閉 Pix_Table 的 cache 功能
disableLog ( mixed $group ) : void disableLog 停用某個 LOG
disableTableCache ( ) : void disableTableCache 停用 Table Cache
dropTable ( ) : void dropTable 刪除這個 table
enableCache ( mixed $group ) : void enableCache 開啟 Pix_Table 的 cache 功能
enableLog ( mixed $group ) : void enableLog 啟用某個 LOG
enableTableCache ( $cache_prefix = '' ) : void enableTableCache 啟用 Table Cache
find ( mixed $primary_value ) : Pix_Table_Row | null find 透過 $primary_value 這個 pk 取得一筆 row
findUniqueKey ( array $columns ) : string | null findUniqueKey 尋找這要用哪一個 Unique Key
find_by ( $columns, $values )
getCache ( )
getCacheStatus ( string $group ) : void getCacheStatus 取得某個 group 的 cache 功能是開是關
getClass ( ) : void getClass 回傳這個 table 的 class name
getDb ( ) : Pix_Table_Db 取得該 Table 專用的 Pix_Table_Db
getDefaultDb ( ) : void getDefaultDb 取得預設的 Db
getFilters ( )
getForceMaster ( ) : boolean getForceMaster 取得是否要強制從 master 抓資料的設定
getHelperManager ( string $type ) : Pix_Helper_Manager getHelperManager get Pix_Helper_Manager from this table
getIndexColumns ( $name )
getIndexes ( ) : array getIndexes get Table index list
getLogStatus ( mixed $group ) : void getLogStatus 取得某個 log 的狀態
getLongQueryTime ( ) getLongQueryTime 取得 Slow query 的設定秒數
getPrimaryColumns ( )
getQueryComment ( ) : null | string getQueryComment 取得要在 db 下 query 時所加上的註解
getRelationForeignKeys ( string $relation ) : array getRelationForeignKeys 取得某個 relation 的 relation name
getRelationForeignTable ( string $relation ) : Pix_Table getRelationForeignTable 取得 relation 對應的 table
getRowFromCache ( array $primary_values ) : false getRowFromCache 從 Cache 中取得 Row
getStaticHelperManager ( string $type ) : Pix_Helper_Manager getStaticHelperManager get Pix_Helper_Manager from static Pix_Table
getTable ( $table = null )
getTableName ( ) : string getTableName 取得 Table 名稱
init ( ) : void init 第一次 load table 進來要做的事,替代掉 __contstruct
insert ( mixed $data ) : void insert 新增一筆資料進資料庫(立刻會存進資料庫)
isEditableKey ( string $key ) : boolean isEditableKey 是否是可以被修改的 Row Key, Ex: column, relation .
isNumbericColumn ( string $column ) : boolean isNumbericColumn 回傳現在這個 column 是不是只有數字
is_a ( Pix_Table_Row $object, string $table ) : boolean is_a $object 是否是 $table 類型的 Row
newEmptyTable ( $table_name = null ) : Pix_Table declare a new empty Pix Table
search ( mixed $where ) : Pix_Table_ResultSet search 搜尋特定條件
setCache ( $cache )
setClassName ( $name )
setDb ( $db )
setDefaultDb ( Pix_Table_Db $db ) : void setDefaultDb 指定 Pix_Table 預設的 db
setForceMaster ( mixed $enable ) : void setForceMaster 設定要不要強制從 master 抓資料。
setLongQueryTime ( integer $second = 1 ) : void setLongQueryTime 當 Query 時間超過這個時間時,會噴出 Warning log
setQueryComment ( null/string $comment = null ) : void setQueryComment 在 Db 下 Query 時,自動加上註解

Protected Methods

Method Description
_getDb ( ) : Pix_Table_Db | mysqli | ... _getDb 給 model 開發者用來回傳

Method Details

__call() public method

public __call ( $name, $args )

__callStatic() public static method

public static __callStatic ( $name, $args )

__construct() public method

public __construct ( )

_getDb() protected method

_getDb 給 model 開發者用來回傳
protected _getDb ( ) : Pix_Table_Db | mysqli | ...
return Pix_Table_Db | mysqli | ...

addFilter() public method

public addFilter ( $filter, $funcname = '' )

addIndex() public static method

addIndex 增加一組 INDEX
public static addIndex ( string $name, array $columns, string $type = 'index' ) : void
$name string 增加 INDEX 名稱
$columns array 哪個 column
$type string index|unique
return void

addResultSetHelper() public static method

addResultSetHelper add ResultSet Helper to this Table
public static addResultSetHelper ( string $helper, array $methods = null, array $options = [] ) : void
$helper string
$methods array
$options array
return void

addRowHelper() public static method

addRowHelper add Row Helper to this Table
public static addRowHelper ( string $helper, array $methods = null, array $options = [] ) : void
$helper string
$methods array
$options array
return void

addStaticResultSetHelper() public static method

addStaticResultSetHelper add ResuletSet Helper to all Table
public static addStaticResultSetHelper ( string $helper, array $methods = null, array $options = [] ) : void
$helper string
$methods array
$options array
return void

addStaticRowHelper() public static method

addStaticRowHelper add Row Helper to all Table
public static addStaticRowHelper ( string $helper, array $methods = null, array $options = [] ) : void
$helper string
$methods array
$options array
return void

addStaticTableHelper() public static method

addStaticTableHelper add Table Helper to all Table
public static addStaticTableHelper ( string $helper, array $methods = null, array $options = [] ) : void
$helper string
$methods array
$options array
return void

addTableHelper() public static method

addTableHelper add Table Helper to this Table
public static addTableHelper ( string $helper, array $methods = null, array $options = [] ) : void
$helper string
$methods array
$options array
return void

bulkInsert() public static method

bulk insert
public static bulkInsert ( array $keys, array $values_list, array $options = [] ) : void
$keys array
$values_list array
$options array (optional)
return void

cacheRow() public method

cacheRow
public cacheRow ( array $primary_values, array $data ) : void
$primary_values array Primary values
$data array
return void

checkTable() public static method

checkTable 檢查 Table 與資料庫上的不同
public static checkTable ( ) : array
return array 不同點

createRow() public static method

createRow 新增加一個未被存入資料庫內的 row
public static createRow ( Pix_Table_Row | null $belong_row = null ) : Pix_Table_Row
$belong_row Pix_Table_Row | null 是從哪個 Row 被 create 出來的,Pix_Table 不會用到,但是先預留
return Pix_Table_Row

createTable() public static method

createTable 在資料庫上建立新 Table
public static createTable ( ) : void
return void

debug() public static method

@codeCoverageIgnoreStart
public static debug ( $word )

disableCache() public static method

disableCache 關閉 Pix_Table 的 cache 功能
public static disableCache ( mixed $group ) : void
$group mixed
return void

disableLog() public static method

disableLog 停用某個 LOG
public static disableLog ( mixed $group ) : void
$group mixed
return void

disableTableCache() public method

disableTableCache 停用 Table Cache
public disableTableCache ( ) : void
return void

dropTable() public static method

dropTable 刪除這個 table
public static dropTable ( ) : void
return void

enableCache() public static method

enableCache 開啟 Pix_Table 的 cache 功能
public static enableCache ( mixed $group ) : void
$group mixed
return void

enableLog() public static method

enableLog 啟用某個 LOG
public static enableLog ( mixed $group ) : void
$group mixed
return void

enableTableCache() public method

enableTableCache 啟用 Table Cache
public enableTableCache ( $cache_prefix = '' ) : void
return void

find() public static method

find 透過 $primary_value 這個 pk 取得一筆 row
public static find ( mixed $primary_value ) : Pix_Table_Row | null
$primary_value mixed
return Pix_Table_Row | null

findUniqueKey() public static method

findUniqueKey 尋找這要用哪一個 Unique Key
public static findUniqueKey ( array $columns ) : string | null
$columns array 有哪些 column
return string | null 哪一組 index

find_by() public static method

public static find_by ( $columns, $values )

getCache() public static method

public static getCache ( )

getCacheStatus() public static method

getCacheStatus 取得某個 group 的 cache 功能是開是關
public static getCacheStatus ( string $group ) : void
$group string
return void

getClass() public method

getClass 回傳這個 table 的 class name
public getClass ( ) : void
return void

getDb() public static method

取得該 Table 專用的 Pix_Table_Db
public static getDb ( ) : Pix_Table_Db
return Pix_Table_Db db

getDefaultDb() public static method

getDefaultDb 取得預設的 Db
public static getDefaultDb ( ) : void
return void

getFilters() public method

public getFilters ( )

getForceMaster() public static method

getForceMaster 取得是否要強制從 master 抓資料的設定
public static getForceMaster ( ) : boolean
return boolean

getHelperManager() public static method

getHelperManager get Pix_Helper_Manager from this table
public static getHelperManager ( string $type ) : Pix_Helper_Manager
$type string
return Pix_Helper_Manager

getIndexColumns() public static method

public static getIndexColumns ( $name )

getIndexes() public static method

getIndexes get Table index list
public static getIndexes ( ) : array
return array

getLogStatus() public static method

getLogStatus 取得某個 log 的狀態
public static getLogStatus ( mixed $group ) : void
$group mixed
return void

getLongQueryTime() public static method

getLongQueryTime 取得 Slow query 的設定秒數
public static getLongQueryTime ( )

getPrimaryColumns() public method

public getPrimaryColumns ( )

getQueryComment() public static method

getQueryComment 取得要在 db 下 query 時所加上的註解
public static getQueryComment ( ) : null | string
return null | string

getRelationForeignKeys() public static method

getRelationForeignKeys 取得某個 relation 的 relation name
public static getRelationForeignKeys ( string $relation ) : array
$relation string relation 名稱
return array relation 的 columns

getRelationForeignTable() public static method

getRelationForeignTable 取得 relation 對應的 table
public static getRelationForeignTable ( string $relation ) : Pix_Table
$relation string relation 名稱
return Pix_Table 對應的 table

getRowFromCache() public method

getRowFromCache 從 Cache 中取得 Row
public getRowFromCache ( array $primary_values ) : false
$primary_values array Primary values
return false - 沒有 cache 到或不支援 cache, null - cache 到 null, Pix_Table_Row cache 到的 row

getStaticHelperManager() public static method

getStaticHelperManager get Pix_Helper_Manager from static Pix_Table
public static getStaticHelperManager ( string $type ) : Pix_Helper_Manager
$type string
return Pix_Helper_Manager

getTable() public static method

public static getTable ( $table = null )

getTableName() public static method

getTableName 取得 Table 名稱
public static getTableName ( ) : string
return string

init() public method

init 第一次 load table 進來要做的事,替代掉 __contstruct
public init ( ) : void
return void

insert() public static method

insert 新增一筆資料進資料庫(立刻會存進資料庫)
public static insert ( mixed $data ) : void
$data mixed
return void

isEditableKey() public static method

..
public static isEditableKey ( string $key ) : boolean
$key string
return boolean

isNumbericColumn() public method

isNumbericColumn 回傳現在這個 column 是不是只有數字
public isNumbericColumn ( string $column ) : boolean
$column string column name
return boolean

is_a() public static method

is_a $object 是否是 $table 類型的 Row
public static is_a ( Pix_Table_Row $object, string $table ) : boolean
$object Pix_Table_Row
$table string
return boolean

newEmptyTable() public static method

declare a new empty Pix Table
public static newEmptyTable ( $table_name = null ) : Pix_Table
return Pix_Table

setCache() public static method

public static setCache ( $cache )

setClassName() public method

public setClassName ( $name )

setDb() public static method

public static setDb ( $db )

setDefaultDb() public static method

setDefaultDb 指定 Pix_Table 預設的 db
public static setDefaultDb ( Pix_Table_Db $db ) : void
$db Pix_Table_Db 用哪個 db
return void

setForceMaster() public static method

setForceMaster 設定要不要強制從 master 抓資料。
public static setForceMaster ( mixed $enable ) : void
$enable mixed
return void

setLongQueryTime() public static method

setLongQueryTime 當 Query 時間超過這個時間時,會噴出 Warning log
public static setLongQueryTime ( integer $second = 1 ) : void
$second integer
return void

setQueryComment() public static method

setQueryComment 在 Db 下 Query 時,自動加上註解
public static setQueryComment ( null/string $comment = null ) : void
$comment null/string
return void

Property Details

$_aliases public_oe property

_aliases 建立 relation 的 aliases
public $_aliases

$_cache protected_oe static_oe property

protected static $_cache

$_cache_groups public_oe static_oe property

記錄哪些東西要 Cache
public static $_cache_groups

$_cache_rows public_oe property

public $_cache_rows

$_class protected_oe property

protected $_class

$_columns public_oe property

_columns 這個 Table 有哪些 column
public $_columns

$_db protected_oe property

protected $_db

$_default_db protected_oe static_oe property

@codeCoverageIgnoreEnd
protected static $_default_db

$_filters protected_oe property

protected $_filters

$_force_master public_oe static_oe property

public static $_force_master

$_helper_managers protected_oe property

protected $_helper_managers

$_hooks public_oe property

_hooks 這個 Table 有哪些 hook
public $_hooks

$_index_datas protected_oe property

protected $_index_datas

$_indexes public_oe property

_indexes 該 Table 用到的 index
Deprecation: use Table->addIndex instead
public array $_indexes
return array

$_log_groups public_oe static_oe property

記錄哪些東西要 Log
public static $_log_groups

$_name public_oe property

_name 這個 Table 在 Db 上面的名稱是什麼
public string $_name
return string

$_primary public_oe property

_primary Primary key, 可以是
public string|array $_primary
return string | array

$_query_comment protected_oe static_oe property

protected static $_query_comment

$_relations public_oe property

_relations 這個 Table 有哪些 relation
public $_relations

$_resultSetClass public_oe property

_resultSetClass 這個 Table 的 ResultSet class
public string $_resultSetClass
return string

$_rowClass public_oe property

_rowClass 這個 Table 的 Row class
public string $_rowClass
return string

$_save_memory public_oe static_oe property

public static $_save_memory

$_static_helper_managers protected_oe static_oe property

protected static $_static_helper_managers

$_table_cache protected_oe property

protected $_table_cache

$_table_cache_prefix protected_oe property

protected $_table_cache_prefix

$_table_pool protected_oe static_oe property

protected static $_table_pool

$_throw_incorrect_string_exception public_oe static_oe property

public static $_throw_incorrect_string_exception

$_verify public_oe static_oe property

public static $_verify