Example #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);
    }
}
Example #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);
    }
}
Example #3
0
if (isset($_POST['Name']) && isset($_POST['phoneNumber'])) {
    require 'insert.php';
    $status = insertIntoTable($_POST['Name'], $_POST['phoneNumber']);
    $statusObj = json_encode($status);
    ?>
		<script type="text/javascript">
		alert(<?php 
    echo $statusObj;
    ?>
);
		</script>
	<?php 
}
if (isset($_GET['ID'])) {
    require 'select.php';
    $result = selectFromTable($_GET['ID']);
    if ($result == false) {
        ?>
			<script type="text/javascript">
			alert("no entry for id = <?php 
        echo $_GET['ID'];
        ?>
");
			</script>
		<?php 
    } else {
        $decoded_result = json_decode($result);
        ?>
			<script type="text/javascript">
			var alertString = "id = <?php 
        echo $decoded_result->ID;
Example #4
0
            $m = 7;
            break;
        case 7:
            $n = 8;
            $m = 8;
            break;
        case 8:
            $n = 9;
            $m = 9;
            break;
        case 9:
            $n = 10;
            $m = 10;
            break;
    }
    $e = selectFromTable($id);
    $finalArray = array('N' => $n, 'M' => $m, 'E' => $e);
    echo json_encode($finalArray);
}
if ($command == 'submit') {
    $id = $_GET["graph_id"];
    $matchArray = json_decode($_GET['solution']);
    $e = selectEdges($id);
    $diff = array();
    for ($i = 0; $i < count($matchArray); $i++) {
        if (!in_array($matchArray[$i], $e)) {
            array_push($diff, $matchArray[$i]);
        }
    }
    if (!empty($diff)) {
        $finalArray = array('graph_id' => $id, 'new_best' => NULL, 'num_match' => 'DNE', 'match_score' => $diff);
Example #5
0
        die("ERROR: recordset_to_htmltable: missing arguments");
    } else {
        //Set the counter. This is used later to set the first row as headers.
        $counter = 0;
        $textOutput = "";
        //Begin constructing the string which will contain the HTML code for the table. Each new line will be concatenated on to this variable
        //Loop trough the recordset.
        while ($row = mysql_fetch_array($recordSet)) {
            //Extract the values and add them to the HTML.
            for ($column = 0; $column < count($row) / 2; $column++) {
                $textOutput .= $row[$column] . "\n";
            }
            //Increment counter
            $counter += 1;
        }
        return $textOutput;
    }
}
$dbConnection = connectDb('localhost', 'webapp', 'vmJ0@DE4sH6NKp4%HD%shF7BJWSIvU', 'content');
$resultsRecordSet = selectFromTable('content_table', 'string', $dbConnection);
if (!empty($resultsRecordSet)) {
    echo recordsetToText($resultsRecordSet, $dbConnection);
} else {
    echo "Failure!\n";
    echo "<p>Unable to retrieve results:</p>\n";
    echo "<p>Error Code:" . mysql_errno() . "</p>\n";
    echo "<p>Error Message:" . mysql_error() . "</p>\n";
}
?>