Return the rules.

@param string|string[] $query

@return string[]
191190
public function rules($query = null)
    {
        $model = $this->model;

        // get rules from the model if set
        if (isset($model::$rules)) {
            $rules = $model::$rules;
        } else {
            $rules = [];
        }

        // if the there are no rules
        if (!is_array($rules) || !$rules) {
            // return an empty array
            return [];
        }

        // if the query is empty
        if (!$query) {
            // return all of the rules
            return array_filter($rules);
        }

        // return the relevant rules
        return array_filter(array_only($rules, $query));
    }
191354
protected function load(Select $query) : array
    {
        $rows = $this->connection->load($query);

        return $this->mapper->loadAll($this->loadingContext, $rows->getRows());
    }
583773
public function search($query)
    {
        $this->logger->debug('Meda:search');
        if (!Tools::isGoodString($query)) {
            $this->logger->error('Media::search: invalid query');
            return [];
        }
        $this->setGeneratorSearch($query, self::MEDIA_NAMESPACE);
        return $this->getImageinfoResponse();
    }
716006
protected function queryFilters($query, $filters = [])
    {
        $filters = $filters ?: $this->filters;

        foreach ($filters as $key => $filter) {
            foreach ($filter as $operator => $values) {
                $values = is_array($values) ? $values : [$values];

                $operator = is_numeric($operator) ? '=' : $operator;

                if ($operator == '=') {
                    $query->whereIn($key, $values);
                } elseif ($operator == '!=') {
                    $query->whereNotIn($key, $values);
                } elseif ($operator == 'null') {
                    $query->whereNull($key);
                } elseif ($operator == 'not_null') {
                    $query->whereNotNull($key);
                } else {
                    $query->where($key, $operator, head($values));
                }
            }
        }

        return $query;
    }
1166090
public static function parseUrlQuery($query)
    {
        $result = [];
        $pairs = explode('&', $query);
        foreach ($pairs as $pair) {
            $parts = explode('=', $pair);
            $rawKey = $parts[0];
            $rawValue = isset($parts[1]) ? $parts[1] : '';
            $value = urldecode($rawValue);
            $key = strtr(urldecode($rawKey), ['[' => '.', ']' => '']);
            Arr::set($result, $key, $value);
        }
        return $result;
    }
932111
private function parseQuery($query)
	{
		$string = '';
		if (is_array($query))
		{
			foreach ($query as $index => $value)
			{
				$string .= !empty($string) ? ' AND ' : '';
				$string .= $index . ':' . $value;
			}
		}
		else
		{
			$string = 'id:' . $query;
		}
		return $string;
	}
88852
public function search($query)
    {
        $this->logger->debug('Category:search:', [$query]);
        if (!Tools::isGoodString($query)) {
            $this->logger->error('Category::search: invalid query');
            return [];
        }
        $this->setGeneratorSearch($query, self::CATEGORY_NAMESPACE);
        return $this->getCategoryinfoResponse();
    }
425137
public function allArray(Query $query = null) {
		$iterator = $this->getIterator();
		$array = $iterator->all($query);
		$array = $this->forgeEntity($array);
		return $array;
	}
257029
public function getTables(string &$query) : array
    {
        $tables = [];
        foreach ($this->tables as &$table) {
            if (strpos($query, $table['table_name']) !== false) {
                $tables[] = $table['table_name'];
            }
        }

        unset($table);
        return $tables;
    }
1228247
private function query($query)
    {
		if(!is_array($query)) {
			return q($query);
		} else {
			foreach($query as $v) {
				q($v);
			}
			return true;
		}
    }
914996
public function getRows($query) {
        try {
            $stmt = $this->db->query($query);
            return $stmt->fetchAll(PDO::FETCH_ASSOC);
        } catch (Exception $e) {
            return [];
        }
    }
988593
public static function getAll($query)
    {
        $ret = array();

        $res = self::query($query);
        if ($res) {
            while ($row = self::connection()->sql_fetch_assoc($res)) {
                $ret[] = $row;
            }
            self::free($res);
        }

        return $ret;
    }
1128592
public function match($query)
    {
        $ruleParts  = explode('/', $this->rule);
        $queryParts = explode('/', $query);

        $ruleCount = count($ruleParts);
        //$querCount = count($queryParts);
        
        $match = false;
        for ($i = 0; $i < $ruleCount; $i++) {
            $rp = $ruleParts[$i];
            $qp = isset($queryParts[$i]) ? $queryParts[$i] : null;
            
            $first = isset($rp[0]) ? $rp[0] : '';
            switch ($first) {
                case '*':
                    $match = true;
                    break;
                
                default:
                    $match = ($rp == $qp);
                    break;
            }
            
            if (!$match) {
                return false;
            }
        }
        
        //echo "$this->rule == $query\n";
        return true;
    }
346543
public function extractQuads($query)
    {
        $quads = [];

        /**
         * Matches the following pattern: Graph <http://uri/> { ?s ?p ?o }
         * Whereas ?s ?p ?o stands for any triple, so also for an URI. It also matches multi line strings
         * which have { and triple on different lines.
         */
        $result = preg_match_all('/GRAPH\s*\<(.*?)\>\s*\{\n*\s*(.*?)\s*\n*\}/si', $query, $matches);

        // if no errors occour and graphs and triple where found
        if (false !== $result
            && true === isset($matches[1])
            && true === isset($matches[2])) {
            foreach ($matches[1] as $key => $graph) {
                // parse according triple string, for instance: <http://saft/test/s1> dc:p1 <http://saft/test/o1>
                // and extract S, P and O.
                $triplePattern = $this->extractTriplePattern($matches[2][$key]);

                // TODO Handle case that more than one triple pattern was found

                if (0 == count($triplePattern)) {
                    throw new \Exception('Quad related part of the query is invalid: '.$matches[2][$key]);
                }

                $quad = $triplePattern[0];
                $quad['g'] = $graph;
                $quad['g_type'] = 'uri';

                $quads[] = $quad;
            }
        }

        return $quads;
    }
348979
public function order($query)
    {
        $clause = '';

        if (!empty($query->order)) {
            $clause = 'ORDER BY ';
            $list = array();
            foreach ($query->order as $order) {
                $columns = AnDomainQueryHelper::parseColumns($query, $order['column']);
                foreach ($columns as $column) {
                    $list[] = $column.' '.$order['direction'];
                }
            }

            $clause .= implode(' , ', $list);
        }

        return $clause;
    }
852360
public function multi_query($query)  {
		$result = array();
		if (mysqli_multi_query($this->driver, $query)) {                                           //执行多个查询
			do {
				if ($this->result = mysqli_store_result($this->driver)) {
					$result[] = $this->getList();
					mysqli_free_result($this->result);
				}
				/*if (mysqli_more_results($this_mysqli)) {
				 echo ("-----------------<br>");                   //连个查询之间的分割线
				 }*/
			} while (mysqli_next_result($this->driver));
		}
		$this->close();
		return $result;
	}
17746
public function search($query)
    {
        $searchProviders = [];

        foreach ($this->searchProviders as $searchProvider) {
            if (!$searchProvider instanceof SearchProviderInterface) {
                continue;
            }

            $role = $searchProvider->getRole();
            if ($role && !$this->authorizationChecker->isGranted($role)) {
                continue;
            }

            $searchProviders[] = $searchProvider;
        }

        $explodedQuery = explode(':', $query);
        if (count($explodedQuery) > 1) {
            $keySearchProviders = [];
            $keyWord = strtolower(array_shift($explodedQuery));

            foreach ($searchProviders as $searchProvider) {
                $searchKey = $searchProvider->getSearchKey();
                if ($searchKey === $keyWord) {
                    $keySearchProviders[] = $searchProvider;
                }
            }

            if (count($keySearchProviders)) {
                $searchProviders = $keySearchProviders;
                $query = trim(implode(':', $explodedQuery));
            }
        }

        $results = [];
        foreach ($searchProviders as $searchProvider) {
            $searchResults = $searchProvider->search($query);
            foreach ($searchResults as $searchResult) {
                $results[] = $searchResult->toArray();
            }
        }

        return $results;
    }