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


PHP DatabaseConnection::get方法代码示例

本文整理汇总了PHP中DatabaseConnection::get方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::get方法的具体用法?PHP DatabaseConnection::get怎么用?PHP DatabaseConnection::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DatabaseConnection的用法示例。


在下文中一共展示了DatabaseConnection::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: select

 public function select($query)
 {
     $link = DatabaseConnection::get();
     $result = mysql_query($query, $link);
     if (!$result) {
         $this->handleDatabaseError($link);
     }
     $rows = array();
     while ($row = mysql_fetch_assoc($result)) {
         array_push($rows, $row);
     }
     DatabaseConnection::closeResult($result);
     DatabaseConnection::closeConnection($link);
     return $rows;
 }
开发者ID:replicair,项目名称:Replicair-website,代码行数:15,代码来源:DatabaseService.php

示例2: get

<?php

class DatabaseConnection
{
    public static function get()
    {
        static $db = null;
        if ($db == null) {
            $db = new DatabaseConnection();
        }
        return $db;
    }
    private $_handle = null;
    private function __construct()
    {
        $this->_handle =& mysql_connect('127.0.0.1', 'root', '12345678');
    }
    public function handle()
    {
        return $this->_handle;
    }
}
print "Handle = " . DatabaseConnection::get()->handle() . "\n";
print "Handle = " . DatabaseConnection::get()->handle() . "\n";
// $db = new DatabaseConnection();
// vim600:ts=4 st=4 foldmethod=marker foldmarker=<<<,>>>
// vim600:syn=php commentstring=//%s
开发者ID:tirozhang,项目名称:morden-php,代码行数:27,代码来源:SingleTon.php

示例3: 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

示例4: JSON_encode

<?php

session_start();
require_once "php/DatabaseConnection.php";
$db = new DatabaseConnection();
$result = $db->get("SELECT * FROM games");
echo JSON_encode($result);
开发者ID:131372,项目名称:informatica-eindopdracht,代码行数:7,代码来源:callDatabase.php

示例5: escapeStr

 public static function escapeStr($value)
 {
     $link = DatabaseConnection::get();
     $value = mysql_escape_string($value);
     DatabaseConnection::closeConnection($link);
     return $value;
 }
开发者ID:replicair,项目名称:Replicair-website,代码行数:7,代码来源:DatabaseConnection.php

示例6: htmlspecialchars

<?php

//process Ajax username request
$username = htmlspecialchars($_REQUEST['username']);
//include db singleton object
require_once 'Singleton.php';
$db = DatabaseConnection::get()->handle();
//$db->debug = true;
//query to check weather username exist
$recordSet =& $db->Execute('select Name from Patterns where Name = "' . $username . '" group by Name');
if ($recordSet->RecordCount() == 1) {
    echo 1;
} else {
    0;
}
$recordSet->Close();
开发者ID:jinahadam,项目名称:Keystroke-Dynamics,代码行数:16,代码来源:check.php

示例7: get

<?php

class DatabaseConnection
{
    public static function get()
    {
        static $db = null;
        if ($db == null) {
            $db = new DatabaseConnection();
        }
        return $db;
    }
    private $_handle = null;
    private function __construct()
    {
        $dsn = 'mysql:host=localhost;dbname=laravel';
        $this->_handle =& new PDO($dsn, 'root', '');
    }
    public function handle()
    {
        return $this->_handle;
    }
}
var_dump(DatabaseConnection::get()->handle());
var_dump(DatabaseConnection::get()->handle());
开发者ID:Overfinch,项目名称:oop,代码行数:25,代码来源:index.php

示例8: 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

示例9: function

 * its default settings. However, you will usually configure
 * your Slim application now by passing an associative array
 * of setting names and values into the application constructor.
 */
$app = new Slim\App();
/**
 * Step 3: Define the Slim application routes
 *
 * Here we define several Slim application routes that respond
 * to appropriate HTTP request methods. In this example, the second
 * argument for `Slim::get`, `Slim::post`, `Slim::put`, `Slim::patch`, and `Slim::delete`
 * is an anonymous function.
 */
$app->get('/', function ($request, $response, $args) {
    $response->write("Welcome to Slim!");
    $connection = DatabaseConnection::get();
    return $response;
});
$app->get('/hello[/{name}]', function ($request, $response, $args) {
    $response->write("Hello, " . $args['name']);
    return $response;
})->setArgument('name', 'World!');
$app->post('/queryServer', function ($request, $response, $args) {
    $response = $response->withAddedHeader('Content-Type', 'application/json');
    $response = $response->withStatus(200);
    $body = $response->getBody();
    $body->write(json_encode(array('salt' => Config_Salts::SaltKey)));
    return $response;
});
/**
 * Step 4: Run the Slim application
开发者ID:IanNorris,项目名称:Confidant,代码行数:31,代码来源:index.php

示例10: DatabaseConnection

<?php

session_start();
require_once "php/DatabaseConnection.php";
$db = new DatabaseConnection();
$result = $db->get("SELECT * FROM gamedata WHERE gameId=:gameId", array(":gameId" => $_SESSION['gameId']));
if (count($result) > 0) {
    echo $result[count($result) - 1]['gamedata'];
}
开发者ID:131372,项目名称:informatica-eindopdracht,代码行数:9,代码来源:getGameState.php


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