本文整理汇总了PHP中DatabaseManager类的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseManager类的具体用法?PHP DatabaseManager怎么用?PHP DatabaseManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatabaseManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAirlines
function getAirlines()
{
$dbMan = new DatabaseManager();
if (!$dbMan->establishConnection()) {
//database connection error
return;
}
$request = new Request('SELECT *', 'se_Airlines');
$request->transformCommand();
$users = $dbMan->executeQuery($request);
//server error
if ($users == null) {
//request was unsuccessful
} else {
if ($users->num_rows) {
/* Get number of rows returned */
$rows = $users->num_rows;
/* For each row - push the airline name
* onto the $airlines array */
for ($i = 0; $i < $rows; ++$i) {
$users->data_seek($i);
$row = $users->fetch_array(MYSQLI_NUM);
echo "<option>" . $row[0] . "</option>";
}
}
}
}
示例2: contact
function contact($name, $email, $subject, $phone, $message)
{
$database_manager = new DatabaseManager();
$json = array();
$body = '<p>
Celular: ' . $phone . '.<br>
Mensaje: ' . $message . '<br><br>
Enviado desde: ' . $_SERVER['SERVER_NAME'] . '
</p>';
try {
if (Send($email, $name, $subject, EMAIL_INFO, $body, $email, $name)) {
$database_manager->Connect();
if ($database_manager->ExecuteProcedure(SP_INSERTA_CONTACTO, '\'' . $name . '\',
\'' . $email . '\',\'' . $subject . '\',\'' . $phone . '\',\'' . $message . '\', \'' . EMAIL_INFO . '\'')) {
$json[] = array('error' => 'false', 'message' => 'Mensaje enviado con éxito.');
} else {
$json[] = array('error' => 'false', 'message' => 'Mensaje enviado con éxito, pero hubo un error al momento de almacenar la información
en la base de datos.');
}
$database_manager->CloseConnection();
}
} catch (Exception $e) {
$json[] = array('error' => 'true', 'message' => 'Hubo un error, por favor, intente nuevamente. Definición del error: ' . $e->getMessage());
}
echo json_encode($json);
}
示例3: approveRestriction
public function approveRestriction($restrictionId, $restrictionTable, $approval)
{
//create instance of Database Manager object
$dbMan = new DatabaseManager();
//establish connection
//if returns false, connection failed
if (!$dbMan->establishConnection()) {
//database connection error
return false;
}
//if approval is true - change restriction status to active
if ($approval) {
/* Create new request to get all pending airline restrictions */
$request = new Request('Approve Restriction', $restrictionTable);
$request->addParameter('restriction_id', $restrictionId);
$request->addParameter('status', 'ACTIVE');
} else {
if (!$approval) {
/* Create new request to get all pending airline restrictions */
$request = new Request('Delete Restriction', $restrictionTable);
$request->addParameter('restriction_id', $restrictionId);
}
}
//transform the command to sql statement
$request->transformCommand();
//execute command
$results = $dbMan->executeQuery($request);
//if results is not null, command was successfully executed.
if ($results != null) {
//successfully approved
return true;
}
//command was not successfully executed.
return false;
}
示例4: backup
/**
* Creates a new backup
*
* @param string $type Accepts 'upgrade' or 'backup'
* @return bool
*/
function backup($type)
{
if (!$this->_enabled) {
return false;
}
$tmp_file = tempnam($this->_store, $type . '_');
$sql_file = $this->_store . DIRECTORY_SEPARATOR . 'backup.sql';
touch($tmp_file);
if (($fh = fopen($tmp_file, 'w+b')) !== false) {
if (flock($fh, LOCK_EX)) {
$dbm = new DatabaseManager($this->_db);
$dbm->backup($fh);
fclose($fh);
chmod($tmp_file, 0666);
if (is_file($sql_file)) {
unlink($sql_file);
}
rename($tmp_file, $sql_file);
$this->compress($type);
if ($this->checkArchive()) {
unlink($sql_file);
}
}
}
}
示例5: move
/**
* Moving participants
*/
public function move()
{
if (count($this->children) > 2) {
//teleport children
while (count($this->children) > 2) {
//child #1, child #2 => teleport
//child #1 <= return
unset($this->children[count($this->children) - 1]);
$this->iterator += 2;
}
}
//teleport adults
foreach ($this->adults as $value) {
//child #1, child #2 => teleport
//child #1 <= return
//adult => teleport
//child #2 <= return
$this->iterator += 4;
}
//child #1, child #2 => teleport
$this->iterator++;
//write log to database
$db_log = new DatabaseManager();
$db_log->writeLog($this->iterator);
}
示例6: checkBlacklist
function checkBlacklist($details)
{
if ($_GET['scope']) {
$dbManager = new DatabaseManager();
$room = $dbManager->getRoom($_GET['scope']);
$whitelist = explode("\n", $room->whitelist);
$blacklist = explode("\n", $room->blacklist);
$artist = strtolower($details["artist"]);
$name = strtolower($details["name"]);
if (count($details)) {
foreach ($whitelist as $term) {
if (strlen($term) > 3 && trim($term)) {
if (stristr($name, $term) or stristr($artist, $term)) {
return true;
}
}
}
foreach ($blacklist as $term) {
if (strlen($term) > 3 && trim($term)) {
if (stristr($name, $term) or stristr($artist, $term)) {
return false;
}
}
}
}
}
return true;
}
示例7: testBasicQuery
public function testBasicQuery()
{
TestManager::loadBasicDummyData();
$database = new DatabaseManager();
$resource = $database->query("SHOW TABLES");
$this->assertNotEquals(false, $resource);
}
示例8: removeRestrictionRequest
public function removeRestrictionRequest($restrictionId, $restrictionTable)
{
//create instance of Database Manager object
$dbMan = new DatabaseManager();
//establish connection
//if returns false, connection failed
if (!$dbMan->establishConnection()) {
//database connection error
return false;
}
/* Create new request to remove restriction*/
$request = new Request('Delete Restriction', $restrictionTable);
$request->addParameter('restriction_id', $restrictionId);
//transform the command to sql statement
$request->transformCommand();
//execute command
$results = $dbMan->executeQuery($request);
//if results is not null, command was successfully executed.
if ($results != null) {
//successfully approved
return true;
}
//command was not successfully executed.
return false;
}
示例9: getPrice
public function getPrice($systemID, $datetime, $priceType)
{
$dbMgr = new DatabaseManager(true);
$price = $dbMgr->getPrice($this->typeID, $systemID, $datetime, $priceType);
$dbMgr = null;
return $price;
}
示例10: __construct
public function __construct($systemID)
{
$dbMgr = new DatabaseManager(true);
$objectData = $dbMgr->getSystemData($systemID);
$this->systemID = $objectData['systemID'];
$this->systemName = $objectData['systemName'];
$dbMgr = null;
}
示例11: setUsername
public function setUsername($name)
{
if ($this->verified) {
$database = new DatabaseManager();
$database->query("UPDATE `users` SET `username`='" . $database->sanitize($name) . "' WHERE `email`='" . $database->sanitize($this->getEmail()) . "'");
apc_store('userObject_' . $this->blid, $this, 600);
}
}
示例12: collectHourStat
function collectHourStat($store = false)
{
$stats = new stdClass();
$stats->time = gmdate("Y-m-d H:00:00", time());
$stats->duration = "hour";
$database = new DatabaseManager();
//Addons!
$addons = new stdClass();
$addonArray = AddonManager::getAll();
$addons->count = sizeof($addonArray);
$addons->cumulative_downloads = array();
$addons->usage = array();
$addons->usage_total = array();
foreach ($addonArray as $addon) {
$downloadData = new stdClass();
// TODO we need to go back. I dont want total downloads, I want individual
//$downloadData->web =
//$downloadData->ingame =
//$downloadData->update =
$addons->cumulative_downloads[$addon->getId()] = $downloadData;
$res = $database->query("SELECT `version` FROM `stats_usage` WHERE `aid`='" . $addon->getId() . "' AND `reported` > now() - INTERVAL 1 HOUR");
$ret = $res->fetch_object();
$usage = array();
$total = 0;
while ($obj = $res->fetch_object()) {
$total++;
if (!isset($usage[$obj->version])) {
$usage[$obj->version] = 1;
} else {
$usage[$obj->version]++;
}
}
$addons->usage[$addon->getId()] = $usage;
$addons->usage_total[$addon->getId()] = $total;
}
$stats->addons = $addons;
//Builds
$builds = new stdClass();
$buildArray = BuildManager::getAll();
$builds->count = sizeof($buildArray);
$builds->cumulative_downloads = array();
foreach ($buildArray as $build) {
// TODO this isn't done either...
//$builds->cumulative_downloads[$build->getId()] = $build->getDownloads();
}
$stats->builds = $builds;
//Master Server
$stats->master = new stdClass();
$master = CronStatManager::getMasterServerStats();
$stats->master->users = $master[0];
$stats->master->servers = $master[1];
if ($store) {
CronStatManager::verifyTable($database);
$database->query("INSERT INTO `cron_statistics` (`time` , `duration` , `data`) VALUES ('" . $stats->time . "', 'hour', '" . $database->sanitize(json_encode($stats)) . "')");
}
return $stats;
}
示例13: getCount
function getCount()
{
if (!isset($numberOfAddons)) {
$db = new DatabaseManager();
$res = $db->query("SELECT COUNT(*) FROM `addon_addons` WHERE board='" . $db->sanitize($this->id) . "' AND deleted=0");
$this->numberOfAddons = $res->fetch_row()[0];
}
return $this->numberOfAddons;
}
示例14: getHistory
public static function getHistory($blid)
{
$db = new DatabaseManager();
$res = $db->query("SELECT * FROM `user_log` WHERE `blid`='" . $db->sanitize($blid) . "' ORDER BY `lastseen` DESC");
$ret = array();
while ($obj = $res->fetch_object()) {
$ret[] = $obj;
}
return $ret;
}
示例15: getAll
public static function getAll()
{
$ret = array();
$db = new DatabaseManager();
$res = $db->query("SELECT `id` FROM `build_builds`");
while ($obj = $res->fetch_object()) {
$ret[$obj->id] = BuildManager::getFromId($obj->id);
}
$res->close();
return $ret;
}