本文整理汇总了PHP中DatabaseConnection::change方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::change方法的具体用法?PHP DatabaseConnection::change怎么用?PHP DatabaseConnection::change使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::change方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DatabaseConnection
<?php
require_once "php/DatabaseConnection.php";
session_start();
$db = new DatabaseConnection();
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$_SESSION['gameInProgress'] = true;
$db->change("INSERT INTO gamedata (gamedata,gameId) VALUES (:gamedata,:gameId)", array(":gamedata" => json_encode($_POST['gameObject']), ":gameId" => $_POST['gameId']));
示例2: DatabaseConnection
<?php
require_once "php/DatabaseConnection.php";
$db = new DatabaseConnection();
$result = $db->get("SELECT * FROM games WHERE id=:id", array(":id" => $_POST['gameId']));
if ($result[0]['guests'] == "") {
$guests = "";
} else {
$guests = explode(",", $result[0]['guests']);
foreach ($guests as $key => $guest) {
if ($guest == $_POST['player']) {
unset($guests[$key]);
}
}
$guests = array_values($guests);
if (count($guests) == 0) {
$guestList = "";
} else {
$guestList = $guests[0];
for ($i = 1; $i < count($guests); $i++) {
$guestList .= "," . $guests[$i];
}
}
}
$db->change("UPDATE games SET guests=:guests WHERE id=:id", array(":id" => $_POST['gameId'], ":guests" => $guestList));
示例3: DatabaseConnection
<?php
session_start();
require_once "php/DatabaseConnection.php";
$db = new DatabaseConnection();
$db->change("INSERT INTO gamedata (gameId,gamedata) VALUES (:gameId,:gamedata)", array(":gameId" => $_SESSION['gameId'], "gamedata" => $_POST['gameObject']));
示例4: DatabaseConnection
<?php
session_start();
require_once "php/DatabaseConnection.php";
$db = new DatabaseConnection();
$result = $db->get("SELECT * FROM games WHERE id=:id", array(":id" => $_SESSION['gameId']));
$result = $result[0]['guests'];
$result = explode(",", $result);
foreach ($result as $key => $guest) {
if ($guest == $_SESSION['username']) {
unset($result[$key]);
}
}
$result = array_values($result);
if (count($result) > 0) {
$guests = $result[0];
for ($i = 1; $i < count($result); $i++) {
$guests .= "," . $result[$i];
}
} else {
$guests = "";
}
$db->change("UPDATE games SET guests=:guests WHERE id=:id", array(":id" => $_SESSION['gameId'], ":guests" => $guests));
unset($_SESSION['username']);
unset($_SESSION['gameId']);
示例5: DatabaseConnection
<?php
session_start();
require_once "php/DatabaseConnection.php";
$db = new DatabaseConnection();
$results1 = $db->get("SELECT * FROM games WHERE gameName=:gameName", array(":gameName" => $_POST['gameName']));
$results2 = $db->get("SELECT * FROM games WHERE hostName=:hostName", array(":hostName" => $_POST['hostName']));
if (count($results1) > 0) {
echo "gameName";
//JSON_encode(array("status"=>"gameName"));
} else {
if (count($results2) > 0) {
echo "hostName";
//JSON_encode(array("status"=>"hostName"));
} else {
$db->change("INSERT INTO games (gameName,hostName,gameType,guests) VALUES (:gameName,:hostName,:gameType,'')", array(":hostName" => $_POST['hostName'], ":gameName" => $_POST['gameName'], ":gameType" => $_POST['gameType']));
$_SESSION['hostName'] = $_POST['hostName'];
$result = $db->get("SELECT * FROM games WHERE hostName=:hostName", array(":hostName" => $_POST['hostName']));
$_SESSION['gameId'] = $result[0]['id'];
echo $_SESSION['gameId'];
}
}
示例6: DatabaseConnection
<?php
session_start();
require_once "php/DatabaseConnection.php";
$db = new DatabaseConnection();
$db->change("DELETE FROM games WHERE id=:id", array(":id" => $_SESSION['gameId']));
unset($_SESSION['hostName']);
unset($_SESSION['gameId']);