samples/PhotoAlbum/lib/rb.php
public static function findOrDispense( $type, $sql, $values ) {
		$foundBeans = self::find($type,$sql,$values);
		if (count($foundBeans)==0) return array(self::dispense($type)); else return $foundBeans;
	}
public static function findOrDispense( $type, $sql, $values ) {
		$foundBeans = self::find($type,$sql,$values);
		if (count($foundBeans)==0) return array(self::dispense($type)); else return $foundBeans;
	}
public static function findOrDispense ( $ type , $ sql , $ values ) { $ foundBeans = self :: find ( $ type , $ sql , $ values ) ; if ( count ( $ foundBeans ) == 0 ) return array ( self :: dispense ( $ type ) ) ; else return $ foundBeans ; }
Convience method. Tries to find beans of a certain type,
if no beans are found, it dispenses a bean of that type.

@param  string $type   type of bean you are looking for
@param  string $sql    SQL code for finding the bean
@param  array  $values parameters to bind to SQL

@return array $beans Contains RedBean_OODBBean instances
Convience method . Tries to find beans of a certain type if no beans are found it dispenses a bean of that type .