本文整理汇总了PHP中XenForo_Application::getDb方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Application::getDb方法的具体用法?PHP XenForo_Application::getDb怎么用?PHP XenForo_Application::getDb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Application
的用法示例。
在下文中一共展示了XenForo_Application::getDb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('tagId' => null, 'position' => 0, 'deleteFirst' => false), $data);
if (!$data['tagId']) {
return false;
}
$db = XenForo_Application::getDb();
$matches = $db->fetchAll("\r\n\t\t\tSELECT tag_content_id, content_type, content_id\r\n\t\t\tFROM xf_tag_content\r\n\t\t\tWHERE tag_id = ?\r\n\t\t\t\tAND tag_content_id > ?\r\n\t\t\tORDER BY tag_content_id\r\n\t\t\tLIMIT 1000\r\n\t\t", array($data['tagId'], $data['position']));
if (!$matches) {
return false;
}
/** @var XenForo_Model_Tag $tagModel */
$tagModel = XenForo_Model::create('XenForo_Model_Tag');
XenForo_Db::beginTransaction($db);
$limitTime = $targetRunTime > 0;
$s = microtime(true);
foreach ($matches as $match) {
$data['position'] = $match['tag_content_id'];
if ($data['deleteFirst']) {
$db->delete('xf_tag_content', 'tag_content_id = ' . $match['tag_content_id']);
}
$tagModel->rebuildTagCache($match['content_type'], $match['content_id']);
if ($limitTime && microtime(true) - $s >= $targetRunTime) {
break;
}
}
XenForo_Db::commit($db);
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('tags');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例2: actionErrorServer
public function actionErrorServer()
{
$upgradePending = false;
try {
$db = XenForo_Application::getDb();
if ($db->isConnected()) {
$dbVersionId = $db->fetchOne("SELECT option_value FROM xf_option WHERE option_id = 'currentVersionId'");
if ($dbVersionId && $dbVersionId != XenForo_Application::$versionId) {
$upgradePending = true;
}
}
} catch (Exception $e) {
}
if (XenForo_Application::debugMode()) {
$showDetails = true;
} else {
if (XenForo_Visitor::hasInstance() && XenForo_Visitor::getInstance()->is_admin) {
$showDetails = true;
} else {
$showDetails = false;
}
}
if ($upgradePending && !$showDetails) {
return $this->responseMessage(new XenForo_Phrase('board_currently_being_upgraded'));
} else {
if ($showDetails) {
$view = $this->responseView('XenForo_ViewPublic_Error_ServerError', 'error_server_error', array('exception' => $this->_request->getParam('_exception')));
$view->responseCode = 500;
return $view;
} else {
return $this->responseError(new XenForo_Phrase('server_error_occurred'), 500);
}
}
}
示例3: install
public static function install($previous)
{
if (XenForo_Application::$versionId < 1020070) {
// note: this can't be phrased
throw new XenForo_Exception('This add-on requires XenForo 1.2.0 or higher.', TRUE);
}
$db = XenForo_Application::getDb();
$tables = self::getTables();
$install = self::DataInstall();
$upgrade = self::DataUpgrade();
if (!$previous) {
foreach ($tables as $tableSql) {
try {
$db->query($tableSql);
} catch (Zend_Db_Exception $e) {
}
}
foreach ($install as $dataSql) {
try {
$db->query($dataSql);
} catch (Zend_Db_Exception $e) {
}
}
} else {
// Upgrade Ads [Advanced]
foreach ($upgrade as $key => $dataSql) {
if ($previous['version_id'] < $key) {
try {
$db->query($dataSql);
} catch (Zend_Db_Exception $e) {
}
}
}
}
}
示例4: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 10), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $albumModel XenGallery_Model_Album */
$albumModel = XenForo_Model::create('XenGallery_Model_Album');
$albumIds = $albumModel->getSharedAlbumIdsInRange($data['position'], $data['batch']);
if (sizeof($albumIds) == 0) {
return true;
}
$db = XenForo_Application::getDb();
XenForo_Db::beginTransaction($db);
foreach ($albumIds as $albumId) {
$data['position'] = $albumId;
$album = $albumModel->getAlbumByIdSimple($albumId);
$bind = array($album['album_id'], $album['album_user_id']);
$ownerShared = $db->fetchOne('SELECT shared_user_id FROM xengallery_shared_map WHERE album_id = ? AND shared_user_id = ?', $bind);
if (!$ownerShared) {
$db->query('
INSERT IGNORE INTO xengallery_shared_map
(album_id, shared_user_id)
VALUES
(?, ?)
', $bind);
}
}
XenForo_Db::commit($db);
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('xengallery_album_permissions');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例5: rebuild
/**
* @param int $position
* @param array $options
* @param string $detailedMessage
* @return bool|int|string|true
*/
public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
{
$options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
/* @var sonnb_XenGallery_Model_Location $locationModel */
$locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
$locations = $locationModel->getLocationsWithoutCoordinate($position, $options['batch']);
if (count($locations) < 1) {
return true;
}
XenForo_Db::beginTransaction();
$db = XenForo_Application::getDb();
/** @var sonnb_XenGallery_Model_Location $locationModel */
$locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
foreach ($locations as $locationId => $location) {
$position = $location['location_id'];
try {
$client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
$response = $client->request('GET');
$response = @json_decode($response->getBody(), true);
if (empty($response['results'][0])) {
continue;
}
$address = $response['results'][0]['formatted_address'];
$lat = $response['results'][0]['geometry']['location']['lat'];
$lng = $response['results'][0]['geometry']['location']['lng'];
$db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
} catch (Exception $e) {
continue;
}
}
XenForo_Db::commit();
$detailedMessage = XenForo_Locale::numberFormat($position);
return $position;
}
示例6: installCustomized
private static function installCustomized($existingAddOn, $addOnData)
{
if (XenForo_Application::$versionId < 1030000) {
throw new XenForo_Exception('[bd] Tag Me v3 requires XenForo 1.3.0+.');
}
$db = XenForo_Application::getDb();
$effectiveVersionId = 0;
if (!empty($existingAddOn)) {
$effectiveVersionId = $existingAddOn['version_id'];
}
if ($effectiveVersionId == 0) {
$db->query("\n\t\t\t\tINSERT IGNORE INTO xf_permission_entry\n\t\t\t\t\t(user_group_id, user_id, permission_group_id, permission_id, permission_value, permission_value_int)\n\t\t\t\tSELECT user_group_id, user_id, 'general', 'bdtagme_groupTag', permission_value, 0\n\t\t\t\tFROM xf_permission_entry\n\t\t\t\tWHERE permission_group_id = 'general' AND permission_id = 'cleanSpam'\n\t\t\t");
}
if ($effectiveVersionId > 0 and $effectiveVersionId < 3062) {
$db->query("UPDATE IGNORE `xf_user_alert` SET action = 'tag' WHERE content_type = 'post' AND action = 'tagged'");
$db->query("UPDATE IGNORE `xf_user_alert` SET action = 'tag' WHERE content_type = 'profile_post' AND action = 'tagged'");
$db->query("UPDATE IGNORE `xf_user_alert` SET action = 'tag_comment' WHERE content_type = 'profile_post' AND action = 'comment_tagged'");
$db->query("UPDATE IGNORE `xf_user_alert_optout` SET alert = 'post_tag' WHERE alert = 'post_tagged'");
$db->query("UPDATE IGNORE `xf_user_alert_optout` SET alert = 'profile_post_tag' WHERE alert = 'profile_post_tagged'");
$db->query("UPDATE IGNORE `xf_user_alert_optout` SET alert = 'profile_post_tag_comment' WHERE alert = 'profile_post_comment_tagged'");
$db->query("DELETE FROM `xf_user_alert_optout` WHERE alert = 'post_tagged'");
$db->query("DELETE FROM `xf_user_alert_optout` WHERE alert = 'profile_post_tagged'");
$db->query("DELETE FROM `xf_user_alert_optout` WHERE alert = 'profile_post_comment_tagged'");
}
}
示例7: helperRichUserName
public static function helperRichUserName(array $user, $usernameHtml = '')
{
if (!is_array($user) || !isset($user['username']) && $usernameHtml === '') {
return '';
}
if ($usernameHtml === '') {
$usernameHtml = htmlspecialchars($user['username']);
}
$stylingOrder = array_map('intval', XenForo_Application::getOptions()->get("3ps_cmfu_markupStylingOrder"));
// sanity checks
if ($stylingOrder["preset"] == 0 && $stylingOrder["user"] == 0) {
return $usernameHtml;
}
if (empty($user['user_id'])) {
$user['display_style_group_id'] = XenForo_Model_User::$defaultGuestGroupId;
} elseif ($user['display_style_group_id'] == null) {
$user['display_style_group_id'] = XenForo_Application::getDb()->fetchOne("SELECT `display_style_group_id` FROM `xf_user` WHERE `user_id` = ?", $user["user_id"]);
}
if (!isset($user["3ps_cmfu_options"])) {
$user["3ps_cmfu_options"] = XenForo_Application::getDb()->fetchOne("SELECT `3ps_cmfu_options` FROM `xf_user` WHERE `user_id`=?", $user["user_id"]);
}
$options = unserialize($user["3ps_cmfu_options"]);
if (!$options) {
$options = ThreePointStudio_CustomMarkupForUser_Constants::$defaultOptionsArray;
XenForo_Model::create("XenForo_Model_User")->insertDefaultCustomMarkup($user["user_id"]);
}
$extraClasses = self::getUserExtraClasses($user);
if (empty($user["user_id"])) {
$html = "{inner}";
} else {
$html = ThreePointStudio_CustomMarkupForUser_Helpers::getCustomMarkupHtml($options, "username", $user, $extraClasses);
}
return str_replace("{inner}", $usernameHtml, $html);
}
示例8: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
return true;
$data = array_merge(array('position' => 0, 'batch' => 10), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $feedbackModel NixFifty_XenTrader_Model_Feedback */
$feedbackModel = XenForo_Model::create('NixFifty_XenTrader_Model_Feedback');
$feedbackItems = $feedbackModel->getUserIdsInFeedbackRange($data['position'], $data['batch']);
if (sizeof($feedbackItems) == 0) {
return true;
}
$db = XenForo_Application::getDb();
XenForo_Db::beginTransaction($db);
foreach ($feedbackItems as $feedbackItem) {
$data['position'] = $item['media_id'];
$feedbackCount = $db->fetchOne('
SELECT COUNT(*)
FROM xf_nixfifty_xentrader_feedback
WHERE to_user_id = ?
', $feedbackItem);
$db->update('xf_nixfifty_xentrader_user', array('total' => $feedbackCount), 'user_id = ' . $db->quote($feedbackItem));
}
XenForo_Db::commit($db);
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = 'fam i think im broken';
//new XenForo_Phrase('xengallery_rebuild_thumbnails');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例9: processInvoices
public static function processInvoices()
{
if (XenForo_Application::$versionId > 1020000) {
$addOns = XenForo_Application::get('addOns');
$isInInstalled = !empty($addOns['ThemeHouse_Invoices']);
} else {
$isInInstalled = $this->getAddOnById('ThemeHouse_Invoices') ? true : false;
}
if (!$isInInstalled) {
return;
}
/* @var $invoiceModel ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_Invoice */
$invoiceModel = XenForo_Model::create('ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_Invoice');
$invoices = $invoiceModel->getPaidInvoices();
$db = XenForo_Application::getDb();
$db->update('invoice_th', array('paid_date' => XenForo_Application::$time), 'paid_state = \'paid\' AND paid_date = \'\'');
$db->update('invoice_th', array('paid_date' => '', 'paid_state' => 'uncleared'), 'paid_date < ' . (XenForo_Application::$time - 60 * 60) . ' AND paid_state = \'paid\' AND payment_method = \'\'');
$unprocessedInvoiceIds = $invoiceModel->getUnprocessedInvoicesFromInvoiceIds(array_keys($invoices));
foreach ($unprocessedInvoiceIds as $invoiceId) {
$invoice = $invoices[$invoiceId];
if (!$db->update('invoice_th', array('paid_state' => 'paid'), 'infusionsoft_invoice_id_th = ' . $db->quote($invoiceId))) {
continue;
}
$db->update('invoice_th', array('paid_date' => XenForo_Application::$time), 'infusionsoft_invoice_id_th = ' . $db->quote($invoiceId));
$db->beginTransaction();
$invoiceModel->processInvoice($invoice);
$db->update('invoice_th', array('payment_method' => 'infusionsoft'), 'infusionsoft_invoice_id_th = ' . $db->quote($invoiceId));
$db->commit();
}
}
示例10: _getDb
protected static function _getDb()
{
if (self::$_db === null) {
self::$_db = XenForo_Application::getDb();
}
return self::$_db;
}
示例11: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'queryKeys' => array('xengallery_media_drop', 'xengallery_media_add', 'xengallery_album', 'xengallery_comment', 'xengallery_user_tag', 'xf_user')), $data);
if (!$data['queryKeys']) {
return true;
}
$s = microtime(true);
$db = XenForo_Application::getDb();
$status = sprintf('%s... %s %s', 'Adding', 'XFMG Table Indexes', str_repeat(' . ', $data['position']));
foreach ($data['queryKeys'] as $key => $name) {
$data['position']++;
$query = $this->_getQueryToExecute($name);
if (!$query) {
continue;
}
try {
$db->query($query);
unset($data['queryKeys'][$key]);
} catch (Zend_Db_Exception $e) {
if ($name != 'xengallery_media_drop') {
XenForo_Error::logException($e, false, "XenForo Media Gallery: Error adding index(es) ({$name}): ");
}
unset($data['queryKeys'][$key]);
continue;
}
if ($targetRunTime && microtime(true) - $s > $targetRunTime) {
break;
}
}
return $data;
}
示例12: _getDb
/**
* Helper method to get the database object.
*
* @return Zend_Db_Adapter_Abstract
*/
protected function _getDb()
{
if ($this->_db === null) {
$this->_db = XenForo_Application::getDb();
}
return $this->_db;
}
示例13: __construct
public function __construct()
{
$this->_db = XenForo_Application::getDb();
$this->_importModel = XenForo_Model::create('XenForo_Model_Import');
$this->_db->setProfiler(false);
// this causes lots of memory usage in debug mode, so stop that
}
示例14: _getTemplatesFromDataSource
protected function _getTemplatesFromDataSource(array $templateList)
{
$db = XenForo_Application::getDb();
$listByLanguageId = array();
foreach ($templateList as $template) {
if (preg_match('#^__(.+)_(\\d+)$#', $template, $matches)) {
$templateName = $matches[1];
$languageId = $matches[2];
if (!isset($listByLanguageId[$languageId])) {
$listByLanguageId[$languageId] = array();
}
$listByLanguageId[$languageId][] = $templateName;
}
}
$results = array();
foreach ($listByLanguageId as $languageId => $templateNames) {
$templates = $db->fetchPairs('
SELECT title, template_compiled
FROM xf_template_compiled
WHERE title IN (' . $db->quote($templateNames) . ')
AND style_id = ?
AND language_id = ?
', array(XenForo_Application::getOptions()->get('defaultStyleId'), $languageId));
foreach ($templates as $title => $compiled) {
$results[sprintf('__%s_%d', $title, $languageId)] = $compiled;
}
}
return $results;
}
示例15: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('batch' => 10, 'position' => 0, 'positionRebuild' => false), $data);
/* @var sonnb_XenGallery_Model_Location $locationModel */
$locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
$locations = $locationModel->getLocationsWithoutCoordinate($data['position'], $data['batch']);
if (count($locations) < 1) {
return false;
}
$db = XenForo_Application::getDb();
/** @var sonnb_XenGallery_Model_Location $locationModel */
$locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
foreach ($locations as $locationId => $location) {
$data['position'] = $location['location_id'];
try {
$client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
$response = $client->request('GET');
$response = @json_decode($response->getBody(), true);
if (empty($response['results'][0])) {
continue;
}
$address = $response['results'][0]['formatted_address'];
$lat = $response['results'][0]['geometry']['location']['lat'];
$lng = $response['results'][0]['geometry']['location']['lng'];
$db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
} catch (Exception $e) {
continue;
}
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('sonnb_xengallery_location');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}