当前位置: 首页>>代码示例>>PHP>>正文


PHP DatabaseConnection::change方法代码示例

本文整理汇总了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']));
开发者ID:131372,项目名称:informatica-eindopdracht,代码行数:12,代码来源:gameStart.php

示例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));
开发者ID:131372,项目名称:informatica-eindopdracht,代码行数:25,代码来源:kickPlayer.php

示例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']));
开发者ID:131372,项目名称:informatica-eindopdracht,代码行数:6,代码来源:uploadGameState.php

示例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']);
开发者ID:131372,项目名称:informatica-eindopdracht,代码行数:25,代码来源:leaveGame.php

示例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'];
    }
}
开发者ID:131372,项目名称:informatica-eindopdracht,代码行数:22,代码来源:startGame.php

示例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']);
开发者ID:131372,项目名称:informatica-eindopdracht,代码行数:8,代码来源:destroyGame.php


注:本文中的DatabaseConnection::change方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。