本文整理汇总了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>
示例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;
}
示例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;
}