RedBeanPHP\Finder::findLike PHP Метод

findLike() публичный Метод

Format of criteria set: property => value The criteria set also supports OR-conditions: property => array( value1, orValue2 ) If the additional SQL is a condition, this condition will be glued to the rest of the query using an AND operator. Note that this is as far as this method can go, there is no way to glue additional SQL using an OR-condition. This method provides access to an underlying mechanism in the RedBeanPHP architecture to find beans using criteria sets. However, please do not use this method for complex queries, use plain SQL instead ( the regular find method ) as it is more suitable for the job. This method is meant for basic search-by-example operations.
public findLike ( string $type, array $conditions = [], string $sql = '' ) : array
$type string type of bean to search for
$conditions array criteria set describing the bean to search for
$sql string additional SQL (for sorting)
Результат array
    public function findLike($type, $conditions = array(), $sql = '')
    {
        if (count($conditions) > 0) {
            foreach ($conditions as $key => $condition) {
                if (!count($condition)) {
                    unset($conditions[$key]);
                }
            }
        }
        return $this->redbean->find($type, $conditions, $sql);
    }

Usage Example

Пример #1
0
 /**
  * Tries to find beans matching the specified type and
  * criteria set.
  *
  * If the optional additional SQL snippet is a condition, it will
  * be glued to the rest of the query using the AND operator.
  *
  * @param string $type type of bean to search for
  * @param array  $like optional criteria set describing the bean to search for
  * @param string $sql  optional additional SQL for sorting
  *
  * @return array
  */
 public static function findLike($type, $like = array(), $sql = '')
 {
     return self::$finder->findLike($type, $like, $sql);
 }