Server-Side Scripting/SQL Databases/PHP

index.php
";   return $result; }

function country_exists($country) { $sql = "       SELECT EXISTS(            SELECT * FROM Countries            WHERE Country = :country) AS Count;    "; $parameters = [ $country ];   $rows = sqlite_query($sql, $parameters); $result = !!$rows[0]["Count"]; return $result; }

function insert_country($country, $temperature) { $sql = "       INSERT INTO Countries (Country, Temperature)        VALUES(:country, :temperature);    "; $parameters = [ $country, $temperature ];   sqlite_exec($sql, $parameters); }

function update_country($country, $temperature) { $sql = "       UPDATE Countries        SET Temperature = :temperature        WHERE Country = :country;    "; $parameters = [ $temperature, $country ];   sqlite_exec($sql, $parameters); }

function delete_country($country) { $sql = "       DELETE FROM Countries        WHERE Country = :country;    "; $parameters = [ $country ];   sqlite_exec($sql, $parameters); }

function sqlite_query($sql, $parameters) { $rows = []; $database = new SQLite3($GLOBALS["DATABASE"]); $statement = $database->prepare($sql); for ($index = 0; $index < count($parameters); $index++) { $statement->bindValue($index + 1, $parameters[$index]); }   $result = $statement->execute; while ($row = $result->fetchArray) { array_push($rows, $row); }   $statement->close; $database->close; return $rows; }

function sqlite_exec($sql, $parameters) { $database = new SQLite3($GLOBALS["DATABASE"]); $statement = $database->prepare($sql); for ($index = 0; $index < count($parameters); $index++) { $statement->bindValue($index + 1, $parameters[$index]); }   $result = $statement->execute; $statement->close; $database->close; }

?>

Try It
Copy and paste the code above into the following free online development environment or use your own compiler / interpreter / IDE.
 * PHPFiddle