PHP 클래스 RedBeanPHP\Repository

OODB manages two repositories, a fluid one that adjust the database schema on-the-fly to accomodate for new bean types (tables) and new properties (columns) and a frozen one for use in a production environment. OODB allows you to swap the repository instances using the freeze() method.
저자: Gabor de Mooij and the RedBeanPHP community
파일 보기 프로젝트 열기: gabordemooij/redbean 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$nesting *
$stash array
$writer RedBeanPHP\Adapter\DBAdapter

공개 메소드들

메소드 설명
__construct ( redbeanphp\OODB $oodb, RedBeanPHP\QueryWriter $writer ) : void Constructor, requires a query writer.
batch ( string $type, array $ids ) : array Returns an array of beans. Pass a type and a series of ids and this method will bring you the corresponding beans.
check ( redbeanphp\OODBBean $bean ) : void Checks whether a OODBBean bean is valid.
convertToBeans ( string $type, array $rows, string $mask = NULL ) : array This is a convenience method; it converts database rows (arrays) into beans. Given a type and a set of rows this method will return an array of beans of the specified type loaded with the data fields provided by the result set from the database.
count ( string $type, string $addSQL = '', array $bindings = [] ) : integer Counts the number of beans of type $type.
find ( string $type, array $conditions = [], $sql = NULL, array $bindings = [] ) : array Searches the database for a bean that matches conditions $conditions and sql $addSQL and returns an array containing all the beans that have been found.
findCollection ( string $type, string $sql, array $bindings = [] ) : redbeanphp\BeanCollection Finds a BeanCollection.
store ( redbeanphp\OODBBean | redbeanphp\SimpleModel $bean ) : integer | string Stores a bean in the database. This method takes a OODBBean Bean Object $bean and stores it in the database. If the database schema is not compatible with this bean and RedBean runs in fluid mode the schema will be altered to store the bean correctly.
tableExists ( string $table ) : boolean Checks whether the specified table already exists in the database.
trash ( redbeanphp\OODBBean | redbeanphp\SimpleModel $bean ) : void Removes a bean from the database.
wipe ( string $type ) : boolean Trash all beans of a given type. Wipes an entire type of bean.

보호된 메소드들

메소드 설명
hasListsOrObjects ( redbeanphp\OODBBean $bean ) : boolean Determines whether the bean has 'loaded lists' or 'loaded embedded beans' that need to be processed by the store() method.
prepareEmbeddedBean ( redbeanphp\OODBBean | redbeanphp\SimpleModel $embeddedBean ) : integer Processes an embedded bean.
processEmbeddedBean ( array &$embeddedBeans, redbeanphp\OODBBean $bean, string $property, redbeanphp\OODBBean $value ) : void Converts an embedded bean to an ID, removed the bean property and stores the bean in the embedded beans array.
processGroups ( array $originals, array $current, array $additions, array $trashcan, array $residue ) : array Process groups. Internal function. Processes different kind of groups for storage function. Given a list of original beans and a list of current beans, this function calculates which beans remain in the list (residue), which have been deleted (are in the trashcan) and which beans have been added (additions).
processResidue ( array $ownresidue ) : void Processes a list of beans from a bean. A bean may contain lists. This method handles own lists; i.e. the $bean->ownObject properties.
processSharedAdditions ( redbeanphp\OODBBean $bean, array $sharedAdditions ) : void Processes a list of beans from a bean. A bean may contain lists. This method handles shared addition lists; i.e. the $bean->sharedObject properties.
processSharedResidue ( redbeanphp\OODBBean $bean, array $sharedresidue ) : void Stores all the beans in the residue group.
processSharedTrashcan ( redbeanphp\OODBBean $bean, array $sharedTrashcan ) : void Unassociates the list items in the trashcan.
processTrashcan ( redbeanphp\OODBBean $bean, array $ownTrashcan ) : void Processes a list of beans from a bean. A bean may contain lists. This method handles own lists; i.e. the $bean->ownObject properties.
storeBeanWithLists ( redbeanphp\OODBBean $bean ) : void Stores a bean and its lists in one run.

메소드 상세

__construct() 공개 메소드

Creates a new instance of the bean respository class.
public __construct ( redbeanphp\OODB $oodb, RedBeanPHP\QueryWriter $writer ) : void
$oodb redbeanphp\OODB
$writer RedBeanPHP\QueryWriter the Query Writer to use for this repository
리턴 void

batch() 공개 메소드

important note: Because this method loads beans using the load() function (but faster) it will return empty beans with ID 0 for every bean that could not be located. The resulting beans will have the passed IDs as their keys.
public batch ( string $type, array $ids ) : array
$type string type of beans
$ids array ids to load
리턴 array

check() 공개 메소드

If the type is not valid or the ID is not valid it will throw an exception: Security.
public check ( redbeanphp\OODBBean $bean ) : void
$bean redbeanphp\OODBBean the bean that needs to be checked
리턴 void

convertToBeans() 공개 메소드

New in 4.3.2: meta mask. The meta mask is a special mask to send data from raw result rows to the meta store of the bean. This is useful for bundling additional information with custom queries. Values of every column whos name starts with $mask will be transferred to the meta section of the bean under key 'data.bundle'.
public convertToBeans ( string $type, array $rows, string $mask = NULL ) : array
$type string type of beans you would like to have
$rows array rows from the database result
$mask string meta mask to apply (optional)
리턴 array

count() 공개 메소드

This method accepts a second argument to modify the count-query. A third argument can be used to provide bindings for the SQL snippet.
public count ( string $type, string $addSQL = '', array $bindings = [] ) : integer
$type string type of bean we are looking for
$addSQL string additional SQL snippet
$bindings array parameters to bind to SQL
리턴 integer

find() 공개 메소드

Conditions need to take form: array( 'PROPERTY' => array( POSSIBLE VALUES... 'John', 'Steve' ) 'PROPERTY' => array( POSSIBLE VALUES... ) ); All conditions are glued together using the AND-operator, while all value lists are glued using IN-operators thus acting as OR-conditions. Note that you can use property names; the columns will be extracted using the appropriate bean formatter.
public find ( string $type, array $conditions = [], $sql = NULL, array $bindings = [] ) : array
$type string type of beans you are looking for
$conditions array list of conditions
$bindings array whether you prefer to use a WHERE clause or not (TRUE = not)
리턴 array

findCollection() 공개 메소드

Finds a BeanCollection.
public findCollection ( string $type, string $sql, array $bindings = [] ) : redbeanphp\BeanCollection
$type string type of beans you are looking for
$sql string SQL to be used in query
$bindings array whether you prefer to use a WHERE clause or not (TRUE = not)
리턴 redbeanphp\BeanCollection

hasListsOrObjects() 보호된 메소드

Determines whether the bean has 'loaded lists' or 'loaded embedded beans' that need to be processed by the store() method.
protected hasListsOrObjects ( redbeanphp\OODBBean $bean ) : boolean
$bean redbeanphp\OODBBean bean to be examined
리턴 boolean

prepareEmbeddedBean() 보호된 메소드

Processes an embedded bean.
protected prepareEmbeddedBean ( redbeanphp\OODBBean | redbeanphp\SimpleModel $embeddedBean ) : integer
$embeddedBean redbeanphp\OODBBean | redbeanphp\SimpleModel the bean or model
리턴 integer

processEmbeddedBean() 보호된 메소드

Converts an embedded bean to an ID, removed the bean property and stores the bean in the embedded beans array.
protected processEmbeddedBean ( array &$embeddedBeans, redbeanphp\OODBBean $bean, string $property, redbeanphp\OODBBean $value ) : void
$embeddedBeans array destination array for embedded bean
$bean redbeanphp\OODBBean target bean to process
$property string property that contains the embedded bean
$value redbeanphp\OODBBean embedded bean itself
리턴 void

processGroups() 보호된 메소드

Process groups. Internal function. Processes different kind of groups for storage function. Given a list of original beans and a list of current beans, this function calculates which beans remain in the list (residue), which have been deleted (are in the trashcan) and which beans have been added (additions).
protected processGroups ( array $originals, array $current, array $additions, array $trashcan, array $residue ) : array
$originals array originals
$current array the current beans
$additions array beans that have been added
$trashcan array beans that have been deleted
$residue array beans that have been left untouched
리턴 array

processResidue() 보호된 메소드

A residue is a bean in an own-list that stays where it is. This method checks if there have been any modification to this bean, in that case the bean is stored once again, otherwise the bean will be left untouched.
protected processResidue ( array $ownresidue ) : void
$ownresidue array list to process
리턴 void

processSharedAdditions() 보호된 메소드

Processes a list of beans from a bean. A bean may contain lists. This method handles shared addition lists; i.e. the $bean->sharedObject properties.
protected processSharedAdditions ( redbeanphp\OODBBean $bean, array $sharedAdditions ) : void
$bean redbeanphp\OODBBean the bean
$sharedAdditions array list with shared additions
리턴 void

processSharedResidue() 보호된 메소드

Stores all the beans in the residue group.
protected processSharedResidue ( redbeanphp\OODBBean $bean, array $sharedresidue ) : void
$bean redbeanphp\OODBBean bean to process
$sharedresidue array list to process
리턴 void

processSharedTrashcan() 보호된 메소드

Unassociates the list items in the trashcan.
protected processSharedTrashcan ( redbeanphp\OODBBean $bean, array $sharedTrashcan ) : void
$bean redbeanphp\OODBBean bean to process
$sharedTrashcan array list to process
리턴 void

processTrashcan() 보호된 메소드

A trash can bean is a bean in an own-list that has been removed (when checked with the shadow). This method checks if the bean is also in the dependency list. If it is the bean will be removed. If not, the connection between the bean and the owner bean will be broken by setting the ID to NULL.
protected processTrashcan ( redbeanphp\OODBBean $bean, array $ownTrashcan ) : void
$bean redbeanphp\OODBBean bean to process
$ownTrashcan array list to process
리턴 void

store() 공개 메소드

If the database schema is not compatible with this bean and RedBean runs in frozen mode it will throw an exception. This function returns the primary key ID of the inserted bean. The return value is an integer if possible. If it is not possible to represent the value as an integer a string will be returned. We use explicit casts instead of functions to preserve performance (0.13 vs 0.28 for 10000 iterations on Core i3).
public store ( redbeanphp\OODBBean | redbeanphp\SimpleModel $bean ) : integer | string
$bean redbeanphp\OODBBean | redbeanphp\SimpleModel bean to store
리턴 integer | string

storeBeanWithLists() 보호된 메소드

Stores a bean and its lists in one run.
protected storeBeanWithLists ( redbeanphp\OODBBean $bean ) : void
$bean redbeanphp\OODBBean bean to process
리턴 void

tableExists() 공개 메소드

Not part of the Object Database interface!
사용 중단: Use AQueryWriter::typeExists() instead.
public tableExists ( string $table ) : boolean
$table string table name
리턴 boolean

trash() 공개 메소드

This function will remove the specified OODBBean Bean Object from the database.
public trash ( redbeanphp\OODBBean | redbeanphp\SimpleModel $bean ) : void
$bean redbeanphp\OODBBean | redbeanphp\SimpleModel bean you want to remove from database
리턴 void

wipe() 공개 메소드

Trash all beans of a given type. Wipes an entire type of bean.
public wipe ( string $type ) : boolean
$type string type of bean you wish to delete all instances of
리턴 boolean

프로퍼티 상세

$nesting 보호되어 있는 프로퍼티

*
protected $nesting

$stash 보호되어 있는 프로퍼티

protected array $stash
리턴 array

$writer 보호되어 있는 프로퍼티

protected DBAdapter,RedBeanPHP\Adapter $writer
리턴 RedBeanPHP\Adapter\DBAdapter