PHP 클래스 RedBeanPHP\Facade

Version Information RedBean Version @version 4
저자: Gabor de Mooij and the RedBeanPHP Community
파일 보기 프로젝트 열기: gabordemooij/redbean 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$currentDB string
$f Not in use (backward compatibility SQLHelper)
$toolbox ToolBox
$toolboxes array

공개 메소드들

메소드 설명
__callStatic ( string $pluginName, array $params ) : mixed Call static for use with dynamic plugins. This magic method will intercept static calls and route them to the specified plugin.
addDatabase ( string $key, string $dsn, string $user = NULL, null | string $pass = NULL, boolean $frozen = FALSE ) : void Adds a database to the facade, afterwards you can select the database using selectDatabase($key), where $key is the name you assigned to this database.
addTags ( OODBBean $bean, array $tagList ) : void Part of RedBeanPHP Tagging API.
aliases ( array $list ) : void Sets global aliases.
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.
beansToArray ( array $beans ) : array Little helper method for Resty Bean Can server and others.
begin ( ) : boolean Facade Convience method for adapter transaction system.
bindFunc ( string $mode, string $field, string $function ) : void Binds an SQL function to a column.
close ( ) : void Closes the database connection.
commit ( ) : boolean Facade Convience method for adapter transaction system.
configureFacadeWithToolbox ( ToolBox $tb ) : ToolBox Configures the facade, want to have a new Writer? A new Object Database or a new Adapter and you want it on-the-fly? Use this method to hot-swap your facade with a new toolbox.
convertToBean ( string $type, array $row, $metamask = NULL ) : array Just like converToBeans, but for one bean.
convertToBeans ( string $type, array $rows, $metamask = NULL ) : array Converts a series of rows to beans.
count ( string $type, string $addSQL = '', array $bindings = [] ) : integer Counts the number of beans of type $type.
debug ( boolean $tf = TRUE, integer $mode ) : RDefault Toggles DEBUG mode.
dispense ( string | array $typeOrBeanArray, $num = 1, boolean $alwaysReturnArray = FALSE ) : array | OODBBean Dispenses a new RedBean OODB Bean for use with the rest of the methods.
dispenseAll ( string $order, boolean $onlyArrays = FALSE ) : array Takes a comma separated list of bean types and dispenses these beans. For each type in the list you can specify the number of beans to be dispensed.
dispenseLabels ( string $type, array $labels ) : array A label is a bean with only an id, type and name property.
dump ( OODBBean | array $data ) : array Simple but effective debug function.
dup ( OODBBean $bean, array $trail = [], boolean $pid = FALSE, $filters = [] ) : array Makes a copy of a bean. This method makes a deep copy of the bean.The copy will have the following features.
duplicate ( OODBBean $bean, $filters = [] ) : array Makes a deep copy of a bean. This method makes a deep copy of the bean.The copy will have the following:
enum ( string $enum ) : array | OODBBean Generates and returns an ENUM value. This is how RedBeanPHP handles ENUMs.
exec ( string $sql, array $bindings = [] ) : integer Convenience function to execute Queries directly.
exportAll ( array | OODBBean $beans, boolean $parents = FALSE, array $filters = [] ) : array Exports a collection of beans. Handy for XML/JSON exports with a Javascript framework like Dojo or ExtJS.
ext ( string $pluginName, callable $callable ) : void Dynamically extends the facade with a plugin.
fancyDebug ( boolean $toggle = TRUE ) : void Turns on the fancy debugger.
find ( string $type, string $sql = NULL, array $bindings = [] ) : array Finds a bean using a type and a where clause (SQL).
findAll ( string $type, string $sql = NULL, array $bindings = [] ) : array
findAndExport ( string $type, string $sql = NULL, array $bindings = [] ) : array
findCollection ( string $type, string $sql = NULL, array $bindings = [] ) : redbeanphp\BeanCollection Finds a bean collection.
findLast ( string $type, string $sql = NULL, array $bindings = [] ) : OODBBean
findLike ( string $type, array $like = [], string $sql = '' ) : array Tries to find beans matching the specified type and criteria set.
findMulti ( array | string $types, $sql, array $bindings = [], array $remappings = [] ) : array Finds multiple types of beans at once and offers additional remapping functionality. This is a very powerful yet complex function.
findOne ( string $type, string $sql = NULL, array $bindings = [] ) : OODBBean
findOneOrDispense ( string $type, string $sql = NULL, array $bindings = [] ) : OODBBean Same as findOrDispense but returns just one element.
findOrCreate ( string $type, array $like = [] ) : OODBBean Tries to find a bean matching a certain type and criteria set. If no beans are found a new bean will be created, the criteria will be imported into this bean and the bean will be stored and returned.
findOrDispense ( string $type, string $sql = NULL, array $bindings = [] ) : array Convience method. Tries to find beans of a certain type, if no beans are found, it dispenses a bean of that type.
flat ( array $array, $result = [] ) : array Flattens a multi dimensional bindings array for use with genSlots().
freeze ( $tf = TRUE ) Toggles fluid or frozen mode. In fluid mode the database structure is adjusted to accomodate your objects. In frozen mode this is not the case.
gatherLabels ( array $beans ) : array Gathers labels from beans. This function loops through the beans, collects the values of the name properties of each individual bean and stores the names in a new array. The array then gets sorted using the default sort function of PHP (sort).
genSlots ( array $array, $template = NULL ) : string Generates question mark slots for an array of values.
getAll ( string $sql, array $bindings = [] ) : array Convenience function to execute Queries directly.
getAssoc ( string $sql, array $bindings = [] ) : array Convenience function to execute Queries directly.
getAssocRow ( string $sql, array $bindings = [] ) : array Convenience function to execute Queries directly.
getCell ( string $sql, array $bindings = [] ) : string Convenience function to execute Queries directly.
getCol ( string $sql, array $bindings = [] ) : array Convenience function to execute Queries directly.
getColumns ( string $table ) : array Returns a list of columns. Format of this array: array( fieldname => type ) Note that this method only works in fluid mode because it might be quite heavy on production servers!
getDatabaseAdapter ( ) : DBAdapter Optional accessor for neat code.
getDuplicationManager ( ) : DuplicationManager Returns the current duplication manager instance.
getExtractedToolbox ( ) : array Mostly for internal use, but might be handy for some users.
getInsertID ( ) : mixed Returns the insert ID for databases that support/require this functionality. Alias for R::getAdapter()->getInsertID().
getLogger ( ) : RedBeanPHP\Logger Returns the current logger instance being used by the database object.
getLogs ( ) : array Returns the log entries written after the startLogging.
getPDO ( ) : null | PDO In case you use PDO (which is recommended and the default but not mandatory, hence the database adapter), you can use this method to obtain the PDO object directly.
getQueryCount ( ) : integer Returns the number of SQL queries processed.
getRedBean ( ) : OODB Optional accessor for neat code.
getRow ( string $sql, array $bindings = [] ) : array Convenience function to execute Queries directly.
getToolBox ( ) : ToolBox Returns the toolbox currently used by the facade.
getVersion ( ) : string Returns the RedBeanPHP version string.
getWriter ( ) : RedBeanPHP\QueryWriter Optional accessor for neat code.
hasDatabase ( string $key ) : boolean Determines whether a database identified with the specified key has already been added to the facade. This function will return TRUE if the database indicated by the key is available and FALSE otherwise.
hasTag ( OODBBean $bean, array $tags, boolean $all = FALSE ) : boolean Part of RedBeanPHP Tagging API.
inspect ( string $type = NULL ) : array Inspects the database schema. If you pass the type of a bean this method will return the fields of its table in the database.
isoDate ( mixed $time = NULL ) : string Simple convenience function, returns ISO date formatted representation of $time.
isoDateTime ( mixed $time = NULL ) : string Simple convenience function, returns ISO date time formatted representation of $time.
load ( string $type, integer $id ) : OODBBean Loads a bean from the object database.
loadAll ( string $type, array $ids ) : array
loadMulti ( string | array $types, mixed $id ) : OODBBean Loads multiple types of beans with the same ID.
nuke ( ) : void Nukes the entire database.
renameAssociation ( string | array $from, string $to = NULL ) : void Facade method for AQueryWriter::renameAssociation()
resetQueryCount ( ) : integer Resets the Query counter.
rollback ( ) : boolean Facade Convience method for adapter transaction system.
selectDatabase ( string $key ) : boolean Selects a different database for the Facade to work with.
setAutoResolve ( boolean $automatic = TRUE ) : void Alias for setAutoResolve() method on OODBBean.
setDatabaseAdapter ( RedBeanPHP\Adapter $adapter ) : void Optional accessor for neat code.
setErrorHandlingFUSE ( integer $mode, callable | null $func = NULL ) : array Sets the error mode for FUSE.
setNarrowFieldMode ( boolean $mode ) : void Toggles Narrow Field Mode.
setRedBean ( OODB $redbean ) Optional accessor for neat code.
setWriter ( RedBeanPHP\QueryWriter $writer ) : void Optional accessor for neat code.
setup ( string $dsn = NULL, string $username = NULL, string $password = NULL, boolean $frozen = FALSE ) : ToolBox Kickstarts redbean for you. This method should be called before you start using RedBean. The Setup() method can be called without any arguments, in this case it will try to create a SQLite database in /tmp called red.db (this only works on UNIX-like systems).
startLogging ( ) : void Starts logging queries.
stopLogging ( ) : void Stops logging, comfortable method to stop logging of queries.
store ( OODBBean | 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.
storeAll ( array $beans ) : array Short hand function to store a set of beans at once, IDs will be returned as an array. For information please consult the R::store() function.
tag ( OODBBean $bean, mixed $tagList = NULL ) : string Part of RedBeanPHP Tagging API.
tagged ( string $beanType, array $tagList, string $sql = '', array $bindings = [] ) : array Part of RedBeanPHP Tagging API.
taggedAll ( string $beanType, array $tagList, string $sql = '', array $bindings = [] ) : array Part of RedBeanPHP Tagging API.
testConnection ( ) : boolean Tests the connection.
transaction ( callable $callback ) : mixed Wraps a transaction around a closure or string callback.
trash ( $beanOrType, integer $id = NULL ) : void Removes a bean from the database.
trashAll ( array $beans ) : void Short hand function to trash a set of beans at once.
untag ( OODBBean $bean, array $tagList ) : void Part of RedBeanPHP Tagging API.
useExportCase ( string $caseStyle = 'default' ) : void Selects case style for export.
useWriterCache ( boolean $yesNo ) : void Toggles Writer Cache.
wipe ( string $beanType ) : boolean Wipes all beans of type $beanType.

비공개 메소드들

메소드 설명
query ( string $method, string $sql, array $bindings ) : array Internal Query function, executes the desired query. Used by all facade query functions. This keeps things DRY.

메소드 상세

__callStatic() 공개 정적인 메소드

Call static for use with dynamic plugins. This magic method will intercept static calls and route them to the specified plugin.
public static __callStatic ( string $pluginName, array $params ) : mixed
$pluginName string name of the plugin
$params array list of arguments to pass to plugin method
리턴 mixed

addDatabase() 공개 정적인 메소드

Usage: R::addDatabase( 'database-1', 'sqlite:/tmp/db1.txt' ); R::selectDatabase( 'database-1' ); //to select database again This method allows you to dynamically add (and select) new databases to the facade. Adding a database with the same key will cause an exception.
public static addDatabase ( string $key, string $dsn, string $user = NULL, null | string $pass = NULL, boolean $frozen = FALSE ) : void
$key string ID for the database
$dsn string DSN for the database
$user string user for connection
$pass null | string password for connection
$frozen boolean whether this database is frozen or not
리턴 void

addTags() 공개 정적인 메소드

Adds tags to a bean. If $tagList is a comma separated list of tags all tags will be associated with the bean. You may also pass an array instead of a string.
public static addTags ( OODBBean $bean, array $tagList ) : void
$bean OODBBean bean to tag
$tagList array list of tags to add to bean
리턴 void

aliases() 공개 정적인 메소드

Registers a batch of aliases in one go. This works the same as fetchAs and setAutoResolve but explicitly. For instance if you register the alias 'cover' for 'page' a property containing a reference to a page bean called 'cover' will correctly return the page bean and not a (non-existant) cover bean. R::aliases( array( 'cover' => 'page' ) ); $book = R::dispense( 'book' ); $page = R::dispense( 'page' ); $book->cover = $page; R::store( $book ); $book = $book->fresh(); $cover = $book->cover; echo $cover->getMeta( 'type' ); //page The format of the aliases registration array is: {alias} => {actual type} In the example above we use: cover => page From that point on, every bean reference to a cover will return a 'page' bean. Note that with autoResolve this feature along with fetchAs() is no longer very important, although relying on explicit aliases can be a bit faster.
public static aliases ( array $list ) : void
$list array list of global aliases to use
리턴 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 static batch ( string $type, array $ids ) : array
$type string type of beans
$ids array ids to load
리턴 array

beansToArray() 공개 정적인 메소드

Takes an array of beans and exports each bean. Unlike exportAll this method does not recurse into own lists and shared lists, the beans are exported as-is, only loaded lists are exported.
public static beansToArray ( array $beans ) : array
$beans array beans
리턴 array

begin() 공개 정적인 메소드

Begins a transaction.
public static begin ( ) : boolean
리턴 boolean

bindFunc() 공개 정적인 메소드

This method can be used to setup a decode/encode scheme or perform UUID insertion. This method is especially useful for handling MySQL spatial columns, because they need to be processed first using the asText/GeomFromText functions. Example: R::bindFunc( 'read', 'location.point', 'asText' ); R::bindFunc( 'write', 'location.point', 'GeomFromText' ); Passing NULL as the function will reset (clear) the function for this column/mode.
public static bindFunc ( string $mode, string $field, string $function ) : void
$mode string mode for function: i.e. read or write
$field string field (table.column) to bind function to
$function string SQL function to bind to specified column
리턴 void

close() 공개 정적인 메소드

Closes the database connection.
public static close ( ) : void
리턴 void

commit() 공개 정적인 메소드

Commits a transaction.
public static commit ( ) : boolean
리턴 boolean

configureFacadeWithToolbox() 공개 정적인 메소드

Configures the facade, want to have a new Writer? A new Object Database or a new Adapter and you want it on-the-fly? Use this method to hot-swap your facade with a new toolbox.
public static configureFacadeWithToolbox ( ToolBox $tb ) : ToolBox
$tb ToolBox toolbox to configure facade with
리턴 ToolBox

convertToBean() 공개 정적인 메소드

Just like converToBeans, but for one bean.
또한 보기: convertToBeans for more details.
public static convertToBean ( string $type, array $row, $metamask = NULL ) : array
$type string type of beans to produce
$row array one row from the database
리턴 array

convertToBeans() 공개 정적인 메소드

This method converts a series of rows to beans. The type of the desired output beans can be specified in the first parameter. The second parameter is meant for the database result rows. Usage: $rows = R::getAll( 'SELECT * FROM ...' ) $beans = R::convertToBeans( $rows ); As of version 4.3.2 you can specify a meta-mask. Data from columns with names starting with the value specified in the mask will be transferred to the meta section of a bean (under data.bundle). $rows = R::getAll( 'SELECT FROM... COUNT(*) AS extra_count ...' ); $beans = R::convertToBeans( $rows ); $bean = reset( $beans ); $data = $bean->getMeta( 'data.bundle' ); $extra_count = $data['extra_count'];
public static convertToBeans ( string $type, array $rows, $metamask = NULL ) : array
$type string type of beans to produce
$rows array must contain an array of array
리턴 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 static 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

debug() 공개 정적인 메소드

In Debug mode all SQL that happens under the hood will be printed to the screen and/or logged. If no database connection has been configured using R::setup() or R::selectDatabase() this method will throw an exception. There are 2 debug styles: Classic: separate parameter bindings, explicit and complete but less readable Fancy: interpersed bindings, truncates large strings, highlighted schema changes Fancy style is more readable but sometimes incomplete. The first parameter turns debugging ON or OFF. The second parameter indicates the mode of operation: 0 Log and write to STDOUT classic style (default) 1 Log only, class style 2 Log and write to STDOUT fancy style 3 Log only, fancy style This function always returns the logger instance created to generate the debug messages.
public static debug ( boolean $tf = TRUE, integer $mode ) : RDefault
$tf boolean debug mode (TRUE or FALSE)
$mode integer mode of operation
리턴 RedBeanPHP\Logger\RDefault

dispense() 공개 정적인 메소드

Dispenses a new RedBean OODB Bean for use with the rest of the methods.
public static dispense ( string | array $typeOrBeanArray, $num = 1, boolean $alwaysReturnArray = FALSE ) : array | OODBBean
$typeOrBeanArray string | array type or bean array to import
$alwaysReturnArray boolean if TRUE always returns the result as an array
리턴 array | OODBBean

dispenseAll() 공개 정적인 메소드

Usage: list( $book, $page, $text ) = R::dispenseAll( 'book,page,text' ); This will dispense a book, a page and a text. This way you can quickly dispense beans of various types in just one line of code. Usage: list($book, $pages) = R::dispenseAll('book,page*100'); This returns an array with a book bean and then another array containing 100 page beans.
public static dispenseAll ( string $order, boolean $onlyArrays = FALSE ) : array
$order string a description of the desired dispense order using the syntax above
$onlyArrays boolean return only arrays even if amount < 2
리턴 array

dispenseLabels() 공개 정적인 메소드

This function will dispense beans for all entries in the array. The values of the array will be assigned to the name property of each individual bean.
public static dispenseLabels ( string $type, array $labels ) : array
$type string type of beans you would like to have
$labels array list of labels, names for each bean
리턴 array

dump() 공개 정적인 메소드

Given a one or more beans this method will return an array containing first part of the string representation of each item in the array.
public static dump ( OODBBean | array $data ) : array
$data OODBBean | array either a bean or an array of beans
리턴 array

dup() 공개 정적인 메소드

- All beans in own-lists will be duplicated as well - All references to shared beans will be copied but not the shared beans themselves - All references to parent objects (_id fields) will be copied but not the parents themselves In most cases this is the desired scenario for copying beans. This function uses a trail-array to prevent infinite recursion, if a recursive bean is found (i.e. one that already has been processed) the ID of the bean will be returned. This should not happen though. Note: This function does a reflectional database query so it may be slow.
사용 중단: This function is deprecated in favour of R::duplicate(). This function has a confusing method signature, the R::duplicate() function only accepts two arguments: bean and filters.
public static dup ( OODBBean $bean, array $trail = [], boolean $pid = FALSE, $filters = [] ) : array
$bean OODBBean bean to be copied
$trail array for internal usage, pass array()
$pid boolean for internal usage
리턴 array

duplicate() 공개 정적인 메소드

* All beans in own-lists will be duplicated as well * All references to shared beans will be copied but not the shared beans themselves * All references to parent objects (_id fields) will be copied but not the parents themselves In most cases this is the desired scenario for copying beans. This function uses a trail-array to prevent infinite recursion, if a recursive bean is found (i.e. one that already has been processed) the ID of the bean will be returned. This should not happen though. Note: This function does a reflectional database query so it may be slow. Note: This is a simplified version of the deprecated R::dup() function.
public static duplicate ( OODBBean $bean, $filters = [] ) : array
$bean OODBBean bean to be copied
리턴 array

enum() 공개 정적인 메소드

Either returns a (newly created) bean respresenting the desired ENUM value or returns a list of all enums for the type. To obtain (and add if necessary) an ENUM value: $tea->flavour = R::enum( 'flavour:apple' ); Returns a bean of type 'flavour' with name = apple. This will add a bean with property name (set to APPLE) to the database if it does not exist yet. To obtain all flavours: R::enum('flavour'); To get a list of all flavour names: R::gatherLabels( R::enum( 'flavour' ) );
public static enum ( string $enum ) : array | OODBBean
$enum string either type or type-value
리턴 array | OODBBean

exec() 공개 정적인 메소드

Executes SQL.
public static exec ( string $sql, array $bindings = [] ) : integer
$sql string SQL query to execute
$bindings array a list of values to be bound to query parameters
리턴 integer

exportAll() 공개 정적인 메소드

What will be exported: * contents of the bean * all own bean lists (recursively) * all shared beans (not THEIR own lists)
public static exportAll ( array | OODBBean $beans, boolean $parents = FALSE, array $filters = [] ) : array
$beans array | OODBBean beans to be exported
$parents boolean whether you want parent beans to be exported
$filters array whitelist of types
리턴 array

ext() 공개 정적인 메소드

Using this method you can register your plugin with the facade and then use the plugin by invoking the name specified plugin name as a method on the facade. Usage: R::ext( 'makeTea', function() { ... } ); Now you can use your makeTea plugin like this: R::makeTea();
public static ext ( string $pluginName, callable $callable ) : void
$pluginName string name of the method to call the plugin
$callable callable a PHP callable
리턴 void

fancyDebug() 공개 정적인 메소드

In 'fancy' mode the debugger will output queries with bound parameters inside the SQL itself. This method has been added to offer a convenient way to activate the fancy debugger system in one call.
public static fancyDebug ( boolean $toggle = TRUE ) : void
$toggle boolean TRUE to activate debugger and select 'fancy' mode
리턴 void

find() 공개 정적인 메소드

As with most Query tools in RedBean you can provide values to be inserted in the SQL statement by populating the value array parameter; you can either use the question mark notation or the slot-notation (:keyname).
public static find ( string $type, string $sql = NULL, array $bindings = [] ) : array
$type string the type of bean you are looking for
$sql string SQL query to find the desired bean, starting right after WHERE clause
$bindings array array of values to be bound to parameters in query
리턴 array

findAll() 공개 정적인 메소드

또한 보기: Facade::find The findAll() method differs from the find() method in that it does not assume a WHERE-clause, so this is valid: R::findAll('person',' ORDER BY name DESC '); Your SQL does not have to start with a valid WHERE-clause condition.
public static findAll ( string $type, string $sql = NULL, array $bindings = [] ) : array
$type string the type of bean you are looking for
$sql string SQL query to find the desired bean, starting right after WHERE clause
$bindings array array of values to be bound to parameters in query
리턴 array

findAndExport() 공개 정적인 메소드

또한 보기: Facade::find The variation also exports the beans (i.e. it returns arrays).
public static findAndExport ( string $type, string $sql = NULL, array $bindings = [] ) : array
$type string the type of bean you are looking for
$sql string SQL query to find the desired bean, starting right after WHERE clause
$bindings array array of values to be bound to parameters in query
리턴 array

findCollection() 공개 정적인 메소드

Use this for large datasets.
public static findCollection ( string $type, string $sql = NULL, array $bindings = [] ) : redbeanphp\BeanCollection
$type string the type of bean you are looking for
$sql string SQL query to find the desired bean, starting right after WHERE clause
$bindings array array of values to be bound to parameters in query
리턴 redbeanphp\BeanCollection

findLast() 공개 정적인 메소드

또한 보기: Facade::find This variation returns the last bean only.
public static findLast ( string $type, string $sql = NULL, array $bindings = [] ) : OODBBean
$type string the type of bean you are looking for
$sql string SQL query to find the desired bean, starting right after WHERE clause
$bindings array array of values to be bound to parameters in query
리턴 OODBBean

findLike() 공개 정적인 메소드

If the optional additional SQL snippet is a condition, it will be glued to the rest of the query using the AND operator.
public static findLike ( string $type, array $like = [], string $sql = '' ) : array
$type string type of bean to search for
$like array optional criteria set describing the bean to search for
$sql string optional additional SQL for sorting
리턴 array

findMulti() 공개 정적인 메소드

For details see Finder::findMulti().
또한 보기: Finder::findMulti()
public static findMulti ( array | string $types, $sql, array $bindings = [], array $remappings = [] ) : array
$types array | string a list of bean types to find
$bindings array SQL bindings
$remappings array an array of remapping arrays containing closures
리턴 array

findOne() 공개 정적인 메소드

또한 보기: Facade::find This variation returns the first bean only.
public static findOne ( string $type, string $sql = NULL, array $bindings = [] ) : OODBBean
$type string the type of bean you are looking for
$sql string SQL query to find the desired bean, starting right after WHERE clause
$bindings array array of values to be bound to parameters in query
리턴 OODBBean

findOneOrDispense() 공개 정적인 메소드

Same as findOrDispense but returns just one element.
public static findOneOrDispense ( string $type, string $sql = NULL, array $bindings = [] ) : OODBBean
$type string type of bean you are looking for
$sql string SQL code for finding the bean
$bindings array parameters to bind to SQL
리턴 OODBBean

findOrCreate() 공개 정적인 메소드

If multiple beans match the criteria only the first one will be returned.
public static findOrCreate ( string $type, array $like = [] ) : OODBBean
$type string type of bean to search for
$like array criteria set describing the bean to search for
리턴 OODBBean

findOrDispense() 공개 정적인 메소드

Note that this function always returns an array.
public static findOrDispense ( string $type, string $sql = NULL, array $bindings = [] ) : array
$type string type of bean you are looking for
$sql string SQL code for finding the bean
$bindings array parameters to bind to SQL
리턴 array

flat() 공개 정적인 메소드

Flattens a multi dimensional bindings array for use with genSlots().
public static flat ( array $array, $result = [] ) : array
$array array array to flatten
리턴 array

freeze() 공개 정적인 메소드

You can also pass an array containing a selection of frozen types. Let's call this chilly mode, it's just like fluid mode except that certain types (i.e. tables) aren't touched.
public static freeze ( $tf = TRUE )

gatherLabels() 공개 정적인 메소드

Gathers labels from beans. This function loops through the beans, collects the values of the name properties of each individual bean and stores the names in a new array. The array then gets sorted using the default sort function of PHP (sort).
public static gatherLabels ( array $beans ) : array
$beans array list of beans to loop
리턴 array

genSlots() 공개 정적인 메소드

Generates question mark slots for an array of values.
public static genSlots ( array $array, $template = NULL ) : string
$array array array to generate question mark slots for
리턴 string

getAll() 공개 정적인 메소드

Executes SQL.
public static getAll ( string $sql, array $bindings = [] ) : array
$sql string SQL query to execute
$bindings array a list of values to be bound to query parameters
리턴 array

getAssoc() 공개 정적인 메소드

Executes SQL. Results will be returned as an associative array. The first column in the select clause will be used for the keys in this array and the second column will be used for the values. If only one column is selected in the query, both key and value of the array will have the value of this field for each row.
public static getAssoc ( string $sql, array $bindings = [] ) : array
$sql string SQL query to execute
$bindings array a list of values to be bound to query parameters
리턴 array

getAssocRow() 공개 정적인 메소드

Executes SQL. Results will be returned as an associative array indexed by the first column in the select.
public static getAssocRow ( string $sql, array $bindings = [] ) : array
$sql string SQL query to execute
$bindings array a list of values to be bound to query parameters
리턴 array

getCell() 공개 정적인 메소드

Executes SQL.
public static getCell ( string $sql, array $bindings = [] ) : string
$sql string SQL query to execute
$bindings array a list of values to be bound to query parameters
리턴 string

getCol() 공개 정적인 메소드

Executes SQL.
public static getCol ( string $sql, array $bindings = [] ) : array
$sql string SQL query to execute
$bindings array a list of values to be bound to query parameters
리턴 array

getColumns() 공개 정적인 메소드

Returns a list of columns. Format of this array: array( fieldname => type ) Note that this method only works in fluid mode because it might be quite heavy on production servers!
public static getColumns ( string $table ) : array
$table string name of the table (not type) you want to get columns of
리턴 array

getDatabaseAdapter() 공개 정적인 메소드

Sets the database adapter you want to use.
public static getDatabaseAdapter ( ) : DBAdapter
리턴 RedBeanPHP\Adapter\DBAdapter

getDuplicationManager() 공개 정적인 메소드

Returns the current duplication manager instance.
public static getDuplicationManager ( ) : DuplicationManager
리턴 DuplicationManager

getExtractedToolbox() 공개 정적인 메소드

This returns all the components of the currently selected toolbox. Returns the components in the following order: # OODB instance (getRedBean()) # Database Adapter # Query Writer # Toolbox itself
public static getExtractedToolbox ( ) : array
리턴 array

getInsertID() 공개 정적인 메소드

Returns the insert ID for databases that support/require this functionality. Alias for R::getAdapter()->getInsertID().
public static getInsertID ( ) : mixed
리턴 mixed

getLogger() 공개 정적인 메소드

Returns the current logger instance being used by the database object.
public static getLogger ( ) : RedBeanPHP\Logger
리턴 RedBeanPHP\Logger

getLogs() 공개 정적인 메소드

Returns the log entries written after the startLogging.
public static getLogs ( ) : array
리턴 array

getPDO() 공개 정적인 메소드

This is a convenience method, it will do the same as: R::getDatabaseAdapter()->getDatabase()->getPDO(); If the PDO object could not be found, for whatever reason, this method will return NULL instead.
public static getPDO ( ) : null | PDO
리턴 null | PDO

getQueryCount() 공개 정적인 메소드

Returns the number of SQL queries processed.
public static getQueryCount ( ) : integer
리턴 integer

getRedBean() 공개 정적인 메소드

Sets the database adapter you want to use.
public static getRedBean ( ) : OODB
리턴 OODB

getRow() 공개 정적인 메소드

Executes SQL.
public static getRow ( string $sql, array $bindings = [] ) : array
$sql string SQL query to execute
$bindings array a list of values to be bound to query parameters
리턴 array

getToolBox() 공개 정적인 메소드

To set the toolbox use R::setup() or R::configureFacadeWithToolbox(). To create a toolbox use Setup::kickstart(). Or create a manual toolbox using the ToolBox class.
public static getToolBox ( ) : ToolBox
리턴 ToolBox

getVersion() 공개 정적인 메소드

The RedBeanPHP version string always has the same format "X.Y" where X is the major version number and Y is the minor version number. Point releases are not mentioned in the version string.
public static getVersion ( ) : string
리턴 string

getWriter() 공개 정적인 메소드

Sets the database adapter you want to use.
public static getWriter ( ) : RedBeanPHP\QueryWriter
리턴 RedBeanPHP\QueryWriter

hasDatabase() 공개 정적인 메소드

Determines whether a database identified with the specified key has already been added to the facade. This function will return TRUE if the database indicated by the key is available and FALSE otherwise.
public static hasDatabase ( string $key ) : boolean
$key string the key/name of the database to check for
리턴 boolean

hasTag() 공개 정적인 메소드

Tests whether a bean has been associated with one ore more of the listed tags. If the third parameter is TRUE this method will return TRUE only if all tags that have been specified are indeed associated with the given bean, otherwise FALSE. If the third parameter is FALSE this method will return TRUE if one of the tags matches, FALSE if none match.
public static hasTag ( OODBBean $bean, array $tags, boolean $all = FALSE ) : boolean
$bean OODBBean bean to check for tags
$tags array list of tags
$all boolean whether they must all match or just some
리턴 boolean

inspect() 공개 정적인 메소드

The keys of this array will be the field names and the values will be the column types used to store their values. If no type is passed, this method returns a list of all tables in the database.
public static inspect ( string $type = NULL ) : array
$type string Type of bean (i.e. table) you want to inspect
리턴 array

isoDate() 공개 정적인 메소드

Simple convenience function, returns ISO date formatted representation of $time.
public static isoDate ( mixed $time = NULL ) : string
$time mixed UNIX timestamp
리턴 string

isoDateTime() 공개 정적인 메소드

Simple convenience function, returns ISO date time formatted representation of $time.
public static isoDateTime ( mixed $time = NULL ) : string
$time mixed UNIX timestamp
리턴 string

load() 공개 정적인 메소드

It searches for a OODBBean Bean Object in the database. It does not matter how this bean has been stored. RedBean uses the primary key ID $id and the string $type to find the bean. The $type specifies what kind of bean you are looking for; this is the same type as used with the dispense() function. If RedBean finds the bean it will return the OODB Bean object; if it cannot find the bean RedBean will return a new bean of type $type and with primary key ID 0. In the latter case it acts basically the same as dispense(). Important note: If the bean cannot be found in the database a new bean of the specified type will be generated and returned.
public static load ( string $type, integer $id ) : OODBBean
$type string type of bean you want to load
$id integer ID of the bean you want to load
리턴 OODBBean

loadAll() 공개 정적인 메소드

또한 보기: Facade::batch Alias for batch(). Batch method is older but since we added so-called *All methods like storeAll, trashAll, dispenseAll and findAll it seemed logical to improve the consistency of the Facade API and also add an alias for batch() called loadAll.
public static loadAll ( string $type, array $ids ) : array
$type string type of beans
$ids array ids to load
리턴 array

loadMulti() 공개 정적인 메소드

This might look like a strange method, however it can be useful for loading a one-to-one relation. Usage: list( $author, $bio ) = R::loadMulti( 'author, bio', $id );
public static loadMulti ( string | array $types, mixed $id ) : OODBBean
$types string | array the set of types to load at once
$id mixed the common ID
리턴 OODBBean

nuke() 공개 정적인 메소드

This will remove all schema structures from the database. Only works in fluid mode. Be careful with this method.
public static nuke ( ) : void
리턴 void

renameAssociation() 공개 정적인 메소드

Facade method for AQueryWriter::renameAssociation()
public static renameAssociation ( string | array $from, string $to = NULL ) : void
$from string | array
$to string
리턴 void

resetQueryCount() 공개 정적인 메소드

Resets the Query counter.
public static resetQueryCount ( ) : integer
리턴 integer

rollback() 공개 정적인 메소드

Rolls back a transaction.
public static rollback ( ) : boolean
리턴 boolean

selectDatabase() 공개 정적인 메소드

If you use the R::setup() you don't need this method. This method is meant for multiple database setups. This method selects the database identified by the database ID ($key). Use addDatabase() to add a new database, which in turn can be selected using selectDatabase(). If you use R::setup(), the resulting database will be stored under key 'default', to switch (back) to this database use R::selectDatabase( 'default' ). This method returns TRUE if the database has been switched and FALSE otherwise (for instance if you already using the specified database).
public static selectDatabase ( string $key ) : boolean
$key string Key of the database to select
리턴 boolean

setAutoResolve() 공개 정적인 메소드

Enables or disables auto-resolving fetch types. Auto-resolving aliased parent beans is convenient but can be slower and can create infinite recursion if you used aliases to break cyclic relations in your domain.
public static setAutoResolve ( boolean $automatic = TRUE ) : void
$automatic boolean TRUE to enable automatic resolving aliased parents
리턴 void

setDatabaseAdapter() 공개 정적인 메소드

Sets the database adapter you want to use.
public static setDatabaseAdapter ( RedBeanPHP\Adapter $adapter ) : void
$adapter RedBeanPHP\Adapter Database Adapter for facade to use
리턴 void

setErrorHandlingFUSE() 공개 정적인 메소드

What to do if a FUSE model method does not exist? You can set the following options: * OODBBean::C_ERR_IGNORE (default), ignores the call, returns NULL * OODBBean::C_ERR_LOG, logs the incident using error_log * OODBBean::C_ERR_NOTICE, triggers a E_USER_NOTICE * OODBBean::C_ERR_WARN, triggers a E_USER_WARNING * OODBBean::C_ERR_EXCEPTION, throws an exception * OODBBean::C_ERR_FUNC, allows you to specify a custom handler (function) * OODBBean::C_ERR_FATAL, triggers a E_USER_ERROR Custom handler method signature: handler( array ( 'message' => string 'bean' => OODBBean 'method' => string ) ) This method returns the old mode and handler as an array.
public static setErrorHandlingFUSE ( integer $mode, callable | null $func = NULL ) : array
$mode integer mode, determines how to handle errors
$func callable | null custom handler (if applicable)
리턴 array

setNarrowFieldMode() 공개 정적인 메소드

See documentation in QueryWriter.
public static setNarrowFieldMode ( boolean $mode ) : void
$mode boolean TRUE = Narrow Field Mode
리턴 void

setRedBean() 공개 정적인 메소드

Sets the database adapter you want to use.
public static setRedBean ( OODB $redbean )
$redbean OODB Object Database for facade to use

setWriter() 공개 정적인 메소드

Sets the database adapter you want to use.
public static setWriter ( RedBeanPHP\QueryWriter $writer ) : void
$writer RedBeanPHP\QueryWriter Query Writer instance for facade to use
리턴 void

setup() 공개 정적인 메소드

Kickstarts redbean for you. This method should be called before you start using RedBean. The Setup() method can be called without any arguments, in this case it will try to create a SQLite database in /tmp called red.db (this only works on UNIX-like systems).
public static setup ( string $dsn = NULL, string $username = NULL, string $password = NULL, boolean $frozen = FALSE ) : ToolBox
$dsn string Database connection string
$username string Username for database
$password string Password for database
$frozen boolean TRUE if you want to setup in frozen mode
리턴 ToolBox

startLogging() 공개 정적인 메소드

Use this method to start logging SQL queries being executed by the adapter.
public static startLogging ( ) : void
리턴 void

stopLogging() 공개 정적인 메소드

Stops logging, comfortable method to stop logging of queries.
public static stopLogging ( ) : void
리턴 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.
public static store ( OODBBean | SimpleModel $bean ) : integer | string
$bean OODBBean | SimpleModel bean to store
리턴 integer | string

storeAll() 공개 정적인 메소드

A loop saver.
public static storeAll ( array $beans ) : array
$beans array list of beans to be stored
리턴 array

tag() 공개 정적인 메소드

Tags a bean or returns tags associated with a bean. If $tagList is NULL or omitted this method will return a comma separated list of tags associated with the bean provided. If $tagList is a comma separated list (string) of tags all tags will be associated with the bean. You may also pass an array instead of a string.
public static tag ( OODBBean $bean, mixed $tagList = NULL ) : string
$bean OODBBean bean to tag
$tagList mixed tags to attach to the specified bean
리턴 string

tagged() 공개 정적인 메소드

Returns all beans that have been tagged with one of the tags given.
public static tagged ( string $beanType, array $tagList, string $sql = '', array $bindings = [] ) : array
$beanType string type of bean you are looking for
$tagList array list of tags to match
$sql string additional SQL query snippet
$bindings array a list of values to bind to the query parameters
리턴 array

taggedAll() 공개 정적인 메소드

Returns all beans that have been tagged with ALL of the tags given.
public static taggedAll ( string $beanType, array $tagList, string $sql = '', array $bindings = [] ) : array
$beanType string type of bean you are looking for
$tagList array list of tags to match
$sql string additional SQL query snippet
$bindings array a list of values to bind to the query parameters
리턴 array

testConnection() 공개 정적인 메소드

Returns TRUE if connection has been established and FALSE otherwise.
public static testConnection ( ) : boolean
리턴 boolean

transaction() 공개 정적인 메소드

If an Exception is thrown inside, the operation is automatically rolled back. If no Exception happens, it commits automatically. It also supports (simulated) nested transactions (that is useful when you have many methods that needs transactions but are unaware of each other). Example: $from = 1; $to = 2; $amount = 300; R::transaction(function() use($from, $to, $amount) { $accountFrom = R::load('account', $from); $accountTo = R::load('account', $to); $accountFrom->money -= $amount; $accountTo->money += $amount; R::store($accountFrom); R::store($accountTo); });
public static transaction ( callable $callback ) : mixed
$callback callable Closure (or other callable) with the transaction logic
리턴 mixed

trash() 공개 정적인 메소드

This function will remove the specified OODBBean Bean Object from the database. This facade method also accepts a type-id combination, in the latter case this method will attempt to load the specified bean and THEN trash it.
public static trash ( $beanOrType, integer $id = NULL ) : void
$id integer ID if the bean to trash (optional, type-id variant only)
리턴 void

trashAll() 공개 정적인 메소드

For information please consult the R::trash() function. A loop saver.
public static trashAll ( array $beans ) : void
$beans array list of beans to be trashed
리턴 void

untag() 공개 정적인 메소드

Removes all specified tags from the bean. The tags specified in the second parameter will no longer be associated with the bean.
public static untag ( OODBBean $bean, array $tagList ) : void
$bean OODBBean tagged bean
$tagList array list of tags (names)
리턴 void

useExportCase() 공개 정적인 메소드

This will determine the case style for the keys of exported beans (see exportAll). The following options are accepted: * 'default' RedBeanPHP by default enforces Snake Case (i.e. book_id is_valid ) * 'camel' Camel Case (i.e. bookId isValid ) * 'dolphin' Dolphin Case (i.e. bookID isValid ) Like CamelCase but ID is written all uppercase
public static useExportCase ( string $caseStyle = 'default' ) : void
$caseStyle string case style identifier
리턴 void

useWriterCache() 공개 정적인 메소드

Turns the Writer Cache on or off. The Writer Cache is a simple query based caching system that may improve performance without the need for cache management. This caching system will cache non-modifying queries that are marked with special SQL comments. As soon as a non-marked query gets executed the cache will be flushed. Only non-modifying select queries have been marked therefore this mechanism is a rather safe way of caching, requiring no explicit flushes or reloads. Of course this does not apply if you intend to test or simulate concurrent querying.
public static useWriterCache ( boolean $yesNo ) : void
$yesNo boolean TRUE to enable cache, FALSE to disable cache
리턴 void

wipe() 공개 정적인 메소드

Wipes all beans of type $beanType.
public static wipe ( string $beanType ) : boolean
$beanType string type of bean you want to destroy entirely
리턴 boolean

프로퍼티 상세

$currentDB 공개적으로 정적으로 프로퍼티

public static string $currentDB
리턴 string

$f 공개적으로 정적으로 프로퍼티

Not in use (backward compatibility SQLHelper)
public static $f

$toolbox 공개적으로 정적으로 프로퍼티

public static ToolBox $toolbox
리턴 ToolBox

$toolboxes 공개적으로 정적으로 프로퍼티

public static array $toolboxes
리턴 array