Microweber\Providers\DatabaseManager::query PHP Метод

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

You can use this function to make queries in the db by writing your own sql The results are returned as array or false if nothing is found
public query ( string $q, string | boolean $cache_id = false, string | boolean $cache_group = 'global', boolean $only_query = false, array | boolean $connection_settings = false ) : array | boolean | mixed
$q string Your SQL query
$cache_id string | boolean It will save the query result in the cache. Set to false to disable
$cache_group string | boolean Stores the result in certain cache group. Set to false to disable
$only_query boolean If set to true, will perform only a query without returning a result
$connection_settings array | boolean
Результат array | boolean | mixed
    public function query($q, $cache_id = false, $cache_group = 'global', $only_query = false, $connection_settings = false)
    {
        if (trim($q) == '') {
            return false;
        }
        $error['error'] = array();
        $results = false;
        if ($cache_id != false and $cache_group != false) {
            $cache_id = $cache_id . crc32($q);
            $results = $this->app->cache_manager->get($cache_id, $cache_group);
            if ($results != false) {
                if ($results == '---empty---' or is_array($results) and empty($results)) {
                    return false;
                } else {
                    return $results;
                }
            }
        }
        $q = DB::select($q);
        if ($only_query != false) {
            return true;
        }
        $q = (array) $q;
        if (isset($q[0])) {
            foreach ($q as $k => $v) {
                $q[$k] = (array) $v;
            }
        }
        if ($only_query == false and empty($q) or $q == false and $cache_group != false) {
            if ($cache_id != false) {
                $this->app->cache_manager->save('---empty---', $cache_id, $cache_group);
            }
            return false;
        }
        if ($only_query == false) {
            if ($cache_id != false and $cache_group != false) {
                if (is_array($q) and !empty($q)) {
                    $this->app->cache_manager->save($q, $cache_id, $cache_group);
                } else {
                    $this->app->cache_manager->save('---empty---', $cache_id, $cache_group);
                }
            }
        }
        if ($cache_id != false) {
            $this->app->cache_manager->save($q, $cache_id, $cache_group);
        }
        return $q;
    }