Beispiel #1
0
 private static function _has_voted($id)
 {
     $user = self::_get_voter_id();
     $votedby = db_select_json("simple_surveys", "votedby", "id=@id@", array("id" => $id));
     if (isset($votedby[$user])) {
         return true;
     }
     return false;
 }
Beispiel #2
0
    // If query was successful, retrieve all the rows into an array
    print json_encode(array("sql" => "ok"));
    while ($row = $result->fetch_assoc()) {
        $output[] = $row;
        // echoing JSON response
        print json_encode($row);
    }
}
// TEST
$str = "SELECT name, description FROM Products";
if (isset($_GET['name']) and isset($_GET['description'])) {
    $name = $_GET['name'];
    $description = $_GET['description'];
    $str = $str . " WHERE name = \"" . $name . "\" AND description = \"" . $description . "\";";
} elseif (isset($_GET['name'])) {
    $name = $_GET['name'];
    $str = $str . " WHERE name = \"" . $name . "\";";
} elseif (isset($_GET['description'])) {
    $description = $_GET['description'];
    $str = $str . " WHERE description = \"" . $description . "\";";
} else {
    $str = $str . ";";
}
print "TEST<br />";
db_select_json("SELECT name, description FROM Products;");
print "<br />TEST<br />";
db_select_json("SELECT name, description FROM Products WHERE name = \"pasta\";");
print "<br />TEST<br />";
db_select_json("SELECT name, description FROM Products WHERE name = \"gioppini\";");
print "<br />TEST<br />";
echo $str;