Find.
@param  any ...$arguments (?int|?string $pv)
@return any|null
@throws froq\database\DatabaseException
168005
public function find(...$arguments) // don't define return type, so user can
    {
        $pv = $arguments[0] ?? null;
        $pn = $this->getStackPrimary();
        if ($pn == null) {
            throw new DatabaseException(sprintf("Null \$stackPrimary, set it in '%s' class",
                static::class));
        }

        $pv = $pv ?? $this->getStackPrimaryValue();
        if ($pv === null) {
            return null;
        }

        $query = $this->initQueryBuilder();
        try {
            return $query->select('*')->whereEqual($pn, $pv)->limit(1)->get();
        } catch (\Exception $e) {
            $this->setFail($e);
        }
    }
223629
public static function findBy($criteria = [], $single = false)
    {
        global $wpdb;
        $return = [];
        $query = static::getQueryByCriteria($criteria);
        $dbResults = $wpdb->get_results($query);

        if ($single && isset($dbResults[0])) {
            return static::getModelFromDBObject($dbResults[0]);
        }

        foreach ($dbResults as $object) {
            $return[] = static::getModelFromDBObject($object);
        }

        return $return;
    }
561246
public function find(string $method, $value, array $args = [])
    {
        $isMethod = null;

        $clone = clone $this;
        $clone->elements = array_filter($this->elements, function ($item) use ($method, $value, &$isMethod, $args) {
            return $this->elementMethodCall($method, $item, $isMethod, $args) === $value;
        });

        return $clone;
    }
453131
public function find($condition, $params = NULL, $fields=null, $fetchMode=PDO::FETCH_ASSOC) {
		if (!empty($fields)) $this->driver->field($fields);
		return $this->driver
            ->where($condition, $params)
            ->fetch($fetchMode);
	}
823432
public function brpop(...$arguments)
    {
        $result = $this->command('brpop', $arguments);

        return empty($result) ? null : $result;
    }
1009140
function find(array $logic = null) {

		$logic != null or $logic = [];

		$opt = [];
		foreach (['%fields', '%order_by', '%limit', '%offset'] as $key) {
			if (isset($logic[$key])) {
				$opt[$key] = $logic[$key];
				unset($logic[$key]);
			}
			else { // %filter not set
				$opt[$key] = [];
			}
		}

		$entries = $this->sqlfind
			(
				$logic,
				$opt['%fields'],
				$opt['%order_by'],
				$opt['%limit'],
				$opt['%offset']
			);

		return $this->toModels($entries);
	}
859920
public static function finds($condition = NULL, $rows = 0, $start = 0, $order='', $fields = '*', $object = true) {
        return static::dao($object)->finds($condition,$rows,$start,$order,$fields);
    }
603040
public function find($arg = null, $operator = '=', $fields = array('*'))
    {
        if ($fields[0] == '*') {
            $this->select();
        } else {
            $select_args = '';
            foreach ($fields as $key => $field) {
                if (is_array($field) && is_string($key)) {
                    foreach ($field as $part) {
                        $select_args .= $key . '.' . $part . ', ';
                    }
                } else {
                    $select_args .= $this->oosql_table . '.' . $field . ', ';
                }
            }

            $this->select(rtrim($select_args, ','));
        }
        if (!is_array($arg)) {
            $obj = $this->getEntityObject();
            $pri = $obj->getPrimary();
            if (null !== $arg) {
                $arg = array($pri[0] => $arg);
            }
        }
        $i = 0;
        $flag = '';
        if (is_array($arg)) {
            foreach ($arg as $col => $val) {
                if ($i > 0) {
                    $flag = 'and';
                }
                $this->where("$this->oosql_table.$col $operator ?", $val, $flag);
                $i++;
            }
        }



        return $this;
    }
569849
public static function find( $where = 'all', $options = array() )
	{

		$dbr = wfGetDB( DB_SLAVE );

		if ( !is_array( $where ) && $where == 'all' ) {

			/* Fetch all entities */
			$collection = $dbr->select( static::$table,
				'id',
				array(),
				__METHOD__,
				$options
			);

		} else {

			/* Fetch conditional entities */
			$collection = $dbr->select( static::$table,
				'id',
				$where,
				__METHOD__,
				$options
			);

		}

		/* Check result */
		if ( !$collection ) return array();

		/* Generate array of entities for return */
		$entities = array();
		foreach ( $collection as $row ) {

			/* Create entity */
			$modelClass = get_called_class();
			$entity = new $modelClass($row->id);

			$entities[] = $entity;

		}

		if ( !count( $entities ) ) return array();

		return $entities;

	}
144352
public function findOrInit($conditions = false, $data = array())
    {
        if (!$this->find($conditions)) {
            // Reset status when record not found
            $this->isNew = true;

            !is_array($conditions) && $conditions = array($this->primaryKey => $conditions);

            // Convert to object to array
            if (is_object($data) && method_exists($data, 'toArray')) {
                $data = $data->toArray();
            }

            // conditions data are fillable
            $this->fromArray($data);
            $this->setData($conditions);
        }
        return $this;
    }
45433
protected function initializeFindables($arguments = null): Findables
    {
        return $this->findables->map(function ($findable) use ($arguments) {
            return $this->initializeFindable($findable, $arguments);
        });
    }
162002
public function find($includeArgs = true)
    {
        $args = $this->findArguments();
        $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';

        // HHVM support
        if (defined('HHVM_VERSION')) {
            return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
        }

        // PHP_BINARY return the current sapi executable
        if (PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server', 'phpdbg')) && is_file(PHP_BINARY)) {
            return PHP_BINARY.$args;
        }

        if ($php = getenv('PHP_PATH')) {
            if (!is_executable($php)) {
                return false;
            }

            return $php;
        }

        if ($php = getenv('PHP_PEAR_PHP_BIN')) {
            if (is_executable($php)) {
                return $php;
            }
        }

        $dirs = array(PHP_BINDIR);
        if ('\\' === DIRECTORY_SEPARATOR) {
            $dirs[] = 'C:\xampp\php\\';
        }

        return $this->executableFinder->find('php', false, $dirs);
    }
10724
public function findOne($criteria = null, $projection = null) {

        $items = $this->find($criteria, $projection)->limit(1)->toArray();

        return isset($items[0]) ? $items[0]:null;
    }
898950
public function find(SQLPredicate $condition = null) {
		$this->mapper->connect();
		$table = $this->entityProfile->getEntityTable();
		
		//build fluent query
		$query = $this->mapper->newQuery($this->entityProfile)
		->from($table, Schema::DEFAULT_ALIAS)
		->select($this->getSelectColumns());
		
		//set query condition
		$args = func_get_args();
		if (empty($args) && $this->hasOption('query.filter'))
			$query->where($this->getFilter());
		elseif (isset($condition))
			$query->where(new Filter($args));
		
		//order by
		if ($this->hasOption('query.orderBy'))
			$query->orderBy($this->getOrderBy());
		
		//limit + offset
		if ($this->hasOption('query.limit'))
			$query->limit($this->getOption('query.limit'));
		
		if ($this->hasOption('query.offset'))
			$query->offset($this->getOption('query.offset'));
		
		//distinct
		if ($this->hasOption('query.distinct') && $this->getOption('query.distinct'))
			$query->distinct();
		
		list($sql, $args) = $query->build();
		return $this->mapper->merge($this->clean(['map.type' => $this->getListMappingExpression()]))->execute($sql, $args);
	}
1054022
public function find($criteria = null, $projection = null) {
        return new Cursor($this, $this->database->registerCriteriaFunction($criteria), $projection);
    }
894993
public function fetchAll($style=null, $argument=null, $ctor_args=null)
    {
        $style = is_null($style) ? $this->_fetch_sty : $style;
        $rst   = null;
        try {
            switch ($style)
            {
            case \PDO::FETCH_ASSOC:
                \oci_fetch_all($this->_stmt, $rst, 0, -1, \OCI_FETCHSTATEMENT_BY_ROW + \OCI_ASSOC);
                break;

            case \PDO::FETCH_NUM:
                \oci_fetch_all($this->_stmt, $rst, 0, -1, \OCI_FETCHSTATEMENT_BY_ROW + \OCI_NUM);
                break;

            case \PDO::FETCH_BOTH:
                \oci_fetch_all($this->_stmt, $rst, 0, -1, \OCI_FETCHSTATEMENT_BY_ROW + \OCI_NUM + \OCI_ASSOC);
                break;

            case \PDO::FETCH_COLUMN:
                \oci_fetch_all($this->_stmt, $rst, 0, -1, \OCI_FETCHSTATEMENT_BY_ROW + \OCI_NUM);
                $rst = array_map(
                    function ($vals) use ($argument) {
                        return $vals[intval($argument)];
                    }, $rst
                );
                break;

            case \PDO::FETCH_COLUMN|\PDO::FETCH_GROUP:
                \oci_fetch_all($this->_stmt, $rst, 0, -1, \OCI_FETCHSTATEMENT_BY_ROW + \OCI_NUM);
                $temp = array();
                foreach ($rst as $key => $value) {
                    if (!array_key_exists($value[0], $temp)) {
                        $temp[$value[0]] = array();
                    }
                    array_push($temp[$value[0]], $value[1]);
                }
                $rst = $temp;
                break;

            case \PDO::FETCH_CLASS:
                \oci_fetch_all($this->_stmt, $rst, 0, -1, \OCI_FETCHSTATEMENT_BY_ROW + \OCI_ASSOC);
                $temp = array();
                foreach ($rst as $idx => $data) {
                    array_push($temp, $this->_createObjectFromData($argument, $data));
                }
                $rst  = $temp;
                break;

            case \PDO::FETCH_FUNC:
                if (!function_exists($argument)) {
                    throw new \PDOException("Function $argument does not exists");
                }
                $ref  = new \ReflectionFunction($argument);
                $args = $ref->getNumberOfParameters();
                if ($args<1) {
                    throw new \PDOException("Function $argument can't receive parameters");
                }
                \oci_fetch_all($this->_stmt, $rst, 0, -1, \OCI_FETCHSTATEMENT_BY_ROW + \OCI_NUM);
                foreach ($rst as $idx => $value) {
                    $temp = array();
                    foreach ($value as $key => $data) {
                        array_push($temp, $data);
                    }
                    call_user_func_array($argument, $temp);
                }
                break;
            }
        } catch (\Exception $e) {
            throw new \PDOException($e->getMessage());
        }
        $rst = $this->_fixResultKeys($rst);
        return $rst;
    }
1042768
public static function extract_assoc( $arguments ) {
		$positional_args = array();
		$assoc_args      = array();
		$global_assoc    = array();
		$local_assoc     = array();

		foreach ( $arguments as $arg ) {
			$positional_arg = null;
			$assoc_arg      = null;

			if ( preg_match( '|^--no-([^=]+)$|', $arg, $matches ) ) {
				$assoc_arg = array( $matches[1], false );
			} elseif ( preg_match( '|^--([^=]+)$|', $arg, $matches ) ) {
				$assoc_arg = array( $matches[1], true );
			} elseif ( preg_match( '|^--([^=]+)=(.*)|s', $arg, $matches ) ) {
				$assoc_arg = array( $matches[1], $matches[2] );
			} else {
				$positional = $arg;
			}

			if ( ! is_null( $assoc_arg ) ) {
				$assoc_args[] = $assoc_arg;
				if ( count( $positional_args ) ) {
					$local_assoc[] = $assoc_arg;
				} else {
					$global_assoc[] = $assoc_arg;
				}
			} elseif ( ! is_null( $positional ) ) {
				$positional_args[] = $positional;
			}
		}

		return array( $positional_args, $assoc_args, $global_assoc, $local_assoc );
	}