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


PHP DataManager::GetInstance方法代码示例

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


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

示例1: RedirectResponse

    RedirectResponse('links.php');
}
if (isset($_POST['fleetLink']) && isset($_POST['name'])) {
    $matches;
    if (preg_match('/gang:(?<id>\\d+)/', GetPost('fleetLink'), $matches)) {
        $a = Alliance::EnsureAlliance($brow->AllianceId(), $brow->AllianceName());
        $f = new Fleet();
        $f->Id = $matches['id'];
        $f->AllianceId = $a->Id;
        $f->Name = GetPost('name');
        $f->Added = time();
        if ($f->Validate()) {
            $f->Save();
            // this seems like a good place to delete old fleets
            Fleet::DeleteOldFleets();
            DataManager::GetInstance()->CloseConnection();
            RedirectResponse('links.php');
        }
    }
}
?>

<html>

<head>
	<title>Fleet Links - Add Fleet</title>
</head>

<body>
<h1><a href="index.php">Fleet Links</a></h1>
<h2>Add Fleet</h2>
开发者ID:AustinWise,项目名称:fleet_links,代码行数:31,代码来源:AddFleet.php

示例2: Save

 public function Save()
 {
     if (!$this->Validate()) {
         throw new Exception('Alliance not valid; unable to save.');
     }
     $conn = DataManager::GetInstance()->GetConnection();
     if (!$this->inDatabase) {
         $stmt = $conn->prepare('INSERT INTO alliance (id, name) VALUES (?, ?)');
         $stmt->bind_param('is', $this->Id, $this->Name);
         $stmt->execute();
         $rows = $stmt->affected_rows;
         $stmt->close();
         if ($rows === 1) {
             $this->inDatabase = TRUE;
             return TRUE;
         } else {
             return FALSE;
         }
     } else {
         $stmt = $conn->prepare('UPDATE alliance SET name=? WHERE id=?');
         $stmt->bind_param('si', $this->Name, $this->Id);
         $stmt->execute();
         $rows = $stmt->affected_rows;
         $stmt->close();
         if ($rows === 1) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
     return FALSE;
 }
开发者ID:AustinWise,项目名称:fleet_links,代码行数:32,代码来源:Alliance.php

示例3: Save

 public function Save()
 {
     if (!$this->Validate()) {
         throw new Exception('Fleet not valid; unable to save.');
     }
     $conn = DataManager::GetInstance()->GetConnection();
     if (!$this->inDatabase) {
         $stmt = $conn->prepare('INSERT INTO fleet (id, allianceId, name, added) VALUES (?, ?, ?, ?)');
         $stmt->bind_param('diss', $this->Id, $this->AllianceId, $this->Name, DataManager::FormatTimestampForSql($this->Added));
         $stmt->execute();
         $rows = $stmt->affected_rows;
         $stmt->close();
         if ($rows === 1) {
             $this->inDatabase = TRUE;
             return TRUE;
         } else {
             return FALSE;
         }
     } else {
         $stmt = $conn->prepare('UPDATE fleet SET allianceId=?, name=?, added=? WHERE id=?');
         $stmt->bind_param('issd', $this->AllianceId, $this->Name, DataManager::FormatTimestampForSql($this->Added), $this->Id);
         $stmt->execute();
         $rows = $stmt->affected_rows;
         $stmt->close();
         if ($rows === 1) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
     return FALSE;
 }
开发者ID:AustinWise,项目名称:fleet_links,代码行数:32,代码来源:Fleet.php


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