findOrCreate() public method

Tries to find a bean with certain properties specified in the second parameter ($like). If the bean is found, it will be returned. If multiple beans are found, only the first will be returned. If no beans match the criteria, a new bean will be dispensed, the criteria will be imported as properties and this new bean will be stored and returned. Format of criteria set: property => value The criteria set also supports OR-conditions: property => array( value1, orValue2 )
public findOrCreate ( string $type, array $like = [] ) : redbeanphp\OODBBean
$type string type of bean to search for
$like array criteria set describing bean to search for
return redbeanphp\OODBBean
コード例 #1
0
ファイル: Facade.php プロジェクト: up9cloud/redbean
 /**
  * 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.
  * If multiple beans match the criteria only the first one
  * will be returned.
  *
  * @param string $type type of bean to search for
  * @param array  $like criteria set describing the bean to search for
  *
  * @return OODBBean
  */
 public static function findOrCreate($type, $like = array())
 {
     return self::$finder->findOrCreate($type, $like);
 }