本文整理汇总了PHP中Core::GetDBInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::GetDBInstance方法的具体用法?PHP Core::GetDBInstance怎么用?PHP Core::GetDBInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core::GetDBInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($zohoCrm)
{
$this->zohoCrm = $zohoCrm;
$this->db = Core::GetDBInstance();
$this->zohoMappings = new Scalr_Integration_ZohoCrm_CustomFields();
$this->logger = Logger::getLogger(__CLASS__);
}
示例2: __construct
/**
* Constructor
*
* @param unknown_type $queue_name
*/
public function __construct($queue_name)
{
$this->QueueName = $queue_name;
$this->DB = Core::GetDBInstance(null, true);
$this->ReflectionTask = new ReflectionClass("Task");
$this->LastTaskID = 0;
}
示例3: OnStartForking
public function OnStartForking()
{
Log::Log("Starting 'CleanZombyUsers' cronjob...", E_USER_NOTICE);
$db = Core::GetDBInstance();
$this->ThreadArgs = array();
foreach((array)$db->GetAll("SELECT * FROM users") as $user)
{
$domains = $db->GetOne("SELECT COUNT(*) FROM domains WHERE status='".DOMAIN_STATUS::DELEGATED."' AND userid='{$user['id']}'");
$invoices = $db->GetOne("SELECT COUNT(*) FROM invoices WHERE (status='1' OR (status = '0'
AND TO_DAYS(NOW())-TO_DAYS(dtcreated)<15)) AND userid='{$user['id']}'
");
if ($domains == 0 && $invoices == 0)
{
Log::Log("Found inactive user: {$user['login']} (id = {$user['id']})", E_USER_NOTICE);
$db->Execute("DELETE FROM users WHERE id='{$user['id']}'");
$db->Execute("DELETE FROM invoices WHERE userid='{$user['id']}'");
$db->Execute("DELETE FROM domains WHERE userid='{$user['id']}'");
$db->Execute("DELETE FROM contacts WHERE userid='{$user['id']}'");
}
}
}
示例4: OnCompleteChangeContactRequest
public static function OnCompleteChangeContactRequest($Contact, $op_type, $approved, $request_ok, $error = null)
{
$DB = Core::GetDBInstance();
$userinfo = $DB->GetRow("SELECT * FROM users WHERE id=?", array($Contact->UserID));
$args = array("client" => $userinfo, "Contact" => $Contact, "approved" => $approved, "request_ok" => $request_ok, "error" => $error);
mailer_send("contact_change_request_complete.eml", $args, $userinfo["email"], $userinfo["name"]);
}
示例5: OnStartForking
public function OnStartForking()
{
// Initialization
$Db = Core::GetDBInstance();
$DbDomain = DBDomain::GetInstance();
$Whois = JWhois::GetInstance();
// Grep TLDs
$data = $Db->GetAll("SELECT TLD FROM tlds WHERE modulename = 'Verisign' AND isactive = 1");
foreach ($data as $row) {
$tlds[] = "'{$row['TLD']}'";
}
$tlds = join(',', $tlds);
// Grep domains
$domain_data = $Db->GetAll("\r\n\t\t\t\tSELECT name, TLD FROM domains \r\n\t\t\t\tWHERE\r\n\t\t\t\t-- TLD in matching list\r\n\t\t\t\tTLD IN ({$tlds})\r\n\t\t\t\t-- Today is anniversary of registration\r\n\t\t\t\tAND ((MONTH(NOW()) = MONTH(start_date) AND DAY(NOW()) = DAY(start_date))\r\n\t\t\t\t-- Today is 28/02 and domain was registered 29/02 at leap year \r\n\t\t\t\tOR (MONTH(NOW()) = 2 AND DAY(NOW()) = 28 AND MONTH(start_date) = 2 AND DAY(start_date) = 29))\r\n\t\t\t");
foreach ($domain_data as $row) {
try {
$Domain = $DbDomain->LoadByName($row['name'], $row['TLD']);
$Client = Client::Load($Domain->UserID);
// Send notice
$emlvars = array('whois' => $Whois->Whois($Domain->GetHostName()), 'Client' => $Client);
mailer_send("wdrp_notice.eml", $emlvars, $Client->Email, $Client->Name);
} catch (Exception $e) {
Log::Log(sprintf("Failed to sent notice about %s. %s", "{$row['name']}.{$row['TLD']}", $e->getMessage()), E_ERROR);
}
}
}
示例6: doJob
public static function doJob($job)
{
$db = Core::GetDBInstance(null, true);
$messageSerializer = new Scalr_Messaging_XmlSerializer();
$message = $db->GetRow("SELECT server_id, message, id, handle_attempts FROM messages WHERE id=?", array($job->workload()));
try {
if ($message['handle_attempts'] >= 3) {
$db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::FAILED, $message['id']));
} else {
try {
$DBServer = DBServer::LoadByID($message['server_id']);
} catch (Exception $e) {
$db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::FAILED, $message['id']));
return;
}
if ($DBServer->status == SERVER_STATUS::RUNNING || $DBServer->status == SERVER_STATUS::INIT || $DBServer->status == SERVER_STATUS::IMPORTING || $DBServer->status == SERVER_STATUS::TEMPORARY || $DBServer->status == SERVER_STATUS::PENDING_TERMINATE) {
// Only 0.2-68 or greater version support this feature.
if ($DBServer->IsSupported("0.2-68")) {
$msg = $messageSerializer->unserialize($message['message']);
$DBServer->SendMessage($msg);
} else {
$db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::UNSUPPORTED, $message['id']));
}
} elseif (in_array($DBServer->status, array(SERVER_STATUS::TERMINATED, SERVER_STATUS::PENDING_TERMINATE))) {
$db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::FAILED, $message['id']));
}
}
} catch (Exception $e) {
//var_dump($e->getMessage());
}
}
示例7: StartThread
public function StartThread($module_info)
{
// Reopen database connection in child process
$db = Core::GetDBInstance(null, true);
// Attach mail notifications on registy events
Registry::AttachClassObserver(new EmailToRegistrantObserver());
Registry::AttachClassObserver(new OperationHistory());
Registry::AttachClassObserver(new ManagedDNSRegistryObserver());
$RegFactory = RegistryModuleFactory::GetInstance();
$Registry = $RegFactory->GetRegistryByName($module_info["name"], false);
$Extensions = $Registry->GetManifest()->GetExtensionList();
foreach ($Extensions as $ext)
{
try
{
$r = false;
$r = $RegFactory->GetRegistryByExtension($ext, true, true);
}
catch(Exception $e)
{
$r = false;
}
if ($r && $r->GetModuleName() == $Registry->GetModuleName())
{
Log::Log(sprintf("Processing %s extension with module %s", $ext, $r->GetModuleName()), E_USER_NOTICE);
$r->DispatchPendingOperations();
}
}
}
示例8: getIdByUrlAndAuth
public static function getIdByUrlAndAuth($url, $authInfo)
{
$crypto = new Scalr_Util_CryptoTool(MCRYPT_TRIPLEDES, MCRYPT_MODE_CFB, 24, 8);
$cryptoKey = @file_get_contents(dirname(__FILE__) . "/../../etc/.cryptokey");
$eAuthInfo = $crypto->encrypt(serialize($authInfo), $cryptoKey);
return Core::GetDBInstance()->GetOne("SELECT id FROM dm_sources WHERE `url`=? AND auth_info=?", array($url, $eAuthInfo));
}
示例9: __call
public function __call($method, $args)
{
// If observer enabled
if (!$this->Config || $this->Config->GetFieldByName("IsEnabled")->Value == 0) {
return;
}
$url = $this->Config->GetFieldByName("{$method}NotifyURL");
if (!$url || $url->Value == '') {
return;
}
$DB = Core::GetDBInstance();
// Event message
$message = urlencode($DB->GetOne("SELECT message FROM events WHERE event_id = ?", array($args[0]->GetEventID())));
$ch = @curl_init();
// set URL and other appropriate options
@curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
@curl_setopt($ch, CURLOPT_URL, $url->Value);
@curl_setopt($ch, CURLOPT_HEADER, false);
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, "event={$method}&message={$message}");
// grab URL and pass it to the browser
@curl_exec($ch);
$error = curl_error();
if ($error) {
Logger::getLogger(__CLASS__)->error($error);
}
// close cURL resource, and free up system resources
@curl_close($ch);
}
示例10: startChild
function startChild()
{
// Reopen DB connection in child
$this->db = Core::GetDBInstance(null, true);
// Reconfigure observers;
Scalr::ReconfigureObservers();
}
示例11: OnStartForking
public function OnStartForking()
{
$db = Core::GetDBInstance();
// Clear old instances log
$oldlogtime = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 10, date("Y"));
$db->Execute("DELETE FROM logentries WHERE `time` < {$oldlogtime}");
sleep(60);
$oldlogtime = date("Y-m-d", mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 20, date("Y")));
$db->Execute("DELETE FROM scripting_log WHERE `dtadded` < {$oldlogtime}");
sleep(60);
$oldlogtime = date("Y-m-d", mktime(date("H"), date("i"), date("s"), date("m") - 6, date("d"), date("Y")));
$db->Execute("DELETE FROM events WHERE `dtadded` < {$oldlogtime}");
sleep(60);
$oldlogtime = date("Y-m-d", mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 30, date("Y")));
$db->Execute("DELETE FROM messages WHERE type='out' AND status='1' AND `dtlasthandleattempt` < {$oldlogtime}");
sleep(60);
//Clear old scripting events
$year = date("Y");
$month = date("m", mktime(date("H"), date("i"), date("s"), date("m") - 1, date("d"), date("Y")));
$db->Execute("DELETE FROM `farm_role_scripts` WHERE ismenuitem='0' AND event_name LIKE 'CustomEvent-{$year}{$month}%'");
$db->Execute("DELETE FROM `farm_role_scripts` WHERE ismenuitem='0' AND event_name LIKE 'APIEvent-{$year}{$month}%'");
// Rotate syslog
if ($db->GetOne("SELECT COUNT(*) FROM syslog") > 1000000) {
$dtstamp = date("dmY");
$db->Execute("CREATE TABLE syslog_{$dtstamp} (id INT NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (id))\n ENGINE=MyISAM SELECT dtadded, message, severity, transactionid FROM syslog;");
$db->Execute("TRUNCATE TABLE syslog");
$db->Execute("OPTIMIZE TABLE syslog");
$db->Execute("TRUNCATE TABLE syslog_metadata");
$db->Execute("OPTIMIZE TABLE syslog_metadata");
$this->Logger->debug("Log rotated. New table 'syslog_{$dtstamp}' created.");
}
}
示例12: __call
public function __call($method, $args)
{
// If observer enabled
if (!$this->Config || $this->Config->GetFieldByName("IsEnabled")->Value == 0) {
return;
}
$enabled = $this->Config->GetFieldByName("{$method}Notify");
if (!$enabled || $enabled->Value == 0) {
return;
}
$DB = Core::GetDBInstance();
// Event name
$name = substr($method, 2);
// Event message
$message = $DB->GetOne("SELECT message FROM events WHERE event_id = ?", array($args[0]->GetEventID()));
$farm_name = $DB->GetOne("SELECT name FROM farms WHERE id=?", array($args[0]->GetFarmID()));
// Set subject
if (!$farm_name) {
$this->Mailer->Subject = "{$name} event notification (FarmID: {$args[0]->GetFarmID()})";
} else {
$this->Mailer->Subject = "{$name} event notification (FarmID: {$args[0]->GetFarmID()} FarmName: {$farm_name})";
}
// Set body
$this->Mailer->Body = $message;
// Send mail
$res = $this->Mailer->Send();
if (!$res) {
Logger::getLogger(__CLASS__)->info("Mail sent to '{$this->Config->GetFieldByName("EventMailTo")->Value}'. Result: {$res}");
}
}
示例13: activateOptions
/**
* Setup db connection.
* Based on defined options, this method connects to db defined in {@link $dsn}
* and creates a {@link $table} table if {@link $createTable} is true.
* @return boolean true if all ok.
*/
function activateOptions()
{
$this->db = Core::GetDBInstance();
//null, true);
$this->layout = LoggerReflectionUtils::createObject('LoggerPatternLayoutScalr');
$this->layout->setConversionPattern($this->getSql());
$this->canAppend = true;
}
示例14: __construct
/**
* SQL Paging
*
* @param string $sql SQL Query without LIMIT x,x
* @param integer $page Current page
* @param integer $pagesize Page size
*/
function __construct($sql = null, $page = null, $pagesize = null)
{
parent::__construct($page, 0, $pagesize);
$this->DB = Core::GetDBInstance();
if ($sql) {
$this->SetSQLQuery($sql);
}
}
示例15: loadByVolumeId
/**
* @return DBEBSVolume
* @param string $volumeId
*/
public static function loadByVolumeId($volumeId)
{
$db = Core::GetDBInstance();
$ebs_info = $db->GetRow("SELECT id FROM ec2_ebs WHERE volume_id = ?", array($volumeId));
if (!$ebs_info) {
throw new Exception(sprintf(_("EBS volume ID#%s not found in database"), $volumeId));
}
return self::loadById($ebs_info['id']);
}