示例#1
0
/**
 * This file is a part of MyWebSQL package
 *
 * @file:      modules/query.php
 * @author     Samnan ur Rehman
 * @copyright  (c) 2008-2012 Samnan ur Rehman
 * @web        http://mywebsql.net
 * @license    http://mywebsql.net/license
 */
function processRequest(&$db)
{
    // first time query will be from request, then we will get it from session (applying limit scenario)
    $table_select = v($_REQUEST["id"]) == 'table' ? true : false;
    if ($table_select) {
        $query = selectFromTable($db);
    } else {
        $query = simpleQuery($db);
    }
    if (!$query) {
        createErrorGrid($db, $query);
        return;
    }
    loadDbVars($db);
    if ($db->query($query)) {
        if (!$db->hasResult()) {
            $info = getCommandInfo($query);
            if ($info['dbAltered']) {
                Session::set('db', 'altered', true);
            } else {
                if ($info['setvar'] == TRUE) {
                    setDbVar($info['variable'], $info['value']);
                }
            }
            createInfoGrid($db);
        } else {
            createResultGrid($db);
        }
    } else {
        createErrorGrid($db, $query);
    }
}
示例#2
0
/**
 * This file is a part of MyWebSQL package
 *
 * @file:      modules/query.php
 * @author     Samnan ur Rehman
 * @copyright  (c) 2008-2014 Samnan ur Rehman
 * @web        http://mywebsql.net
 * @license    http://mywebsql.net/license
 */
function processRequest(&$db)
{
    // first time query will be from request, then we will get it from session (applying limit scenario)
    $table_select = v($_REQUEST["id"]) == 'table' ? true : false;
    if ($table_select) {
        $query = selectFromTable($db);
    } else {
        $query = simpleQuery($db);
    }
    if (!$query) {
        createErrorGrid($db, $query);
        return;
    }
    loadDbVars($db);
    if ($db->query($query)) {
        if (!$db->hasResult()) {
            $info = getCommandInfo($query);
            if ($info['dbAltered']) {
                Session::set('db', 'altered', true);
            } else {
                if ($info['setvar'] == TRUE && is_scalar($info['variable']) && is_scalar($info['value'])) {
                    setDbVar($info['variable'], $info['value']);
                }
            }
            createInfoGrid($db);
        } else {
            // if it is a data result set, show it as result grid, otherwise in simple grid layout
            $query_type = getQueryType($query);
            if ($query_type['can_limit']) {
                createResultGrid($db);
            } else {
                createSimpleGrid($db, __('Query') . ': ' . $query);
            }
        }
    } else {
        createErrorGrid($db, $query);
    }
}