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


PHP DateTimeHelper::currentTimeForDb方法代码示例

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


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

示例1: saveSitemap

 /**
  * @param SproutSeo_SitemapModel $attributes
  *
  * @return mixed|null|string
  */
 public function saveSitemap(SproutSeo_SitemapModel $attributes)
 {
     $row = array();
     $isNew = false;
     if (isset($attributes->id) && substr($attributes->id, 0, 3) === "new") {
         $isNew = true;
     }
     if (!$isNew) {
         $row = craft()->db->createCommand()->select('*')->from('sproutseo_sitemap')->where('id=:id', array(':id' => $attributes->id))->queryRow();
     }
     $model = SproutSeo_SitemapModel::populateModel($row);
     $model->id = !$isNew ? $attributes->id : null;
     $model->sectionId = isset($attributes->sectionId) ? $attributes->sectionId : null;
     $model->url = isset($attributes->url) ? $attributes->url : null;
     $model->priority = $attributes->priority;
     $model->changeFrequency = $attributes->changeFrequency;
     $model->enabled = $attributes->enabled == 'true' ? 1 : 0;
     $model->ping = $attributes->ping == 'true' ? 1 : 0;
     $model->dateUpdated = DateTimeHelper::currentTimeForDb();
     $model->uid = StringHelper::UUID();
     if ($isNew) {
         $model->dateCreated = DateTimeHelper::currentTimeForDb();
         craft()->db->createCommand()->insert('sproutseo_sitemap', $model->getAttributes());
         return craft()->db->lastInsertID;
     } else {
         $result = craft()->db->createCommand()->update('sproutseo_sitemap', $model->getAttributes(), 'id=:id', array(':id' => $model->id));
         return $model->id;
     }
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:34,代码来源:SproutSeo_SitemapService.php

示例2: log

 /**
  * Logs a new deprecation error.
  *
  * @param string $key
  * @param string $message
  *
  * @return bool
  */
 public function log($key, $message)
 {
     $log = new DeprecationErrorModel();
     $log->key = $key;
     $log->message = $message;
     $log->lastOccurrence = DateTimeHelper::currentTimeForDb();
     $log->template = craft()->request->isSiteRequest() ? craft()->templates->getRenderingTemplate() : null;
     // Everything else requires the stack trace
     $this->_populateLogWithStackTraceData($log);
     // Don't log the same key/fingerprint twice in the same request
     if (!isset($this->_fingerprints[$log->key]) || !in_array($log->fingerprint, $this->_fingerprints[$log->key])) {
         craft()->db->createCommand()->insertOrUpdate(static::$_tableName, array('key' => $log->key, 'fingerprint' => $log->fingerprint), array('lastOccurrence' => DateTimeHelper::formatTimeForDb($log->lastOccurrence), 'file' => $log->file, 'line' => $log->line, 'class' => $log->class, 'method' => $log->method, 'template' => $log->template, 'templateLine' => $log->templateLine, 'message' => $log->message, 'traces' => JsonHelper::encode($log->traces)));
         $this->_fingerprints[$key][] = $log->fingerprint;
     }
     return true;
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:24,代码来源:DeprecatorService.php

示例3: defineAttributes

 /**
  * @inheritDoc BaseModel::defineAttributes()
  *
  * @return array
  */
 protected function defineAttributes()
 {
     // The client license key.
     $attributes['licenseKey'] = AttributeType::String;
     // The license key status.  Set by the server response.
     $attributes['licenseKeyStatus'] = AttributeType::String;
     // The edition that Craft is licensed to use
     $attributes['licensedEdition'] = array(AttributeType::Enum, 'values' => array(Craft::Personal, Craft::Client, Craft::Pro));
     // The domain that the license is associated with
     $attributes['licensedDomain'] = AttributeType::String;
     // Whether Craft is running for a domain that's eligible to be used in Edition Test Mode
     $attributes['editionTestableDomain'] = AttributeType::Bool;
     // The installed plugin license keys.
     $attributes['pluginLicenseKeys'] = AttributeType::Mixed;
     // The plugins' license key statuses.  Set by the server response.
     $attributes['pluginLicenseKeyStatuses'] = AttributeType::Mixed;
     // Extra arbitrary data to send to the server.
     $attributes['data'] = AttributeType::Mixed;
     // The url making the request.
     $attributes['requestUrl'] = array(AttributeType::String, 'default' => '');
     // The IP address making the request.
     $attributes['requestIp'] = array(AttributeType::String, 'default' => '1.1.1.1');
     // The time the request was made.
     $attributes['requestTime'] = array(AttributeType::DateTime, 'default' => DateTimeHelper::currentTimeForDb());
     // The port number the request comes from.
     $attributes['requestPort'] = AttributeType::String;
     // The local version number.
     $attributes['localVersion'] = array(AttributeType::String, 'required' => true);
     // The local build number.
     $attributes['localBuild'] = array(AttributeType::Number, 'required' => true);
     // The local edition.
     $attributes['localEdition'] = array(AttributeType::String, 'required' => true);
     // The currently logged in user's email address.
     $attributes['userEmail'] = AttributeType::Email;
     // The track this install is on.  Not required for backwards compatibility.
     $attributes['track'] = array(AttributeType::String);
     // Whether or not to show beta releases.
     $attributes['showBeta'] = AttributeType::Bool;
     // Any errors to return;
     $attributes['errors'] = AttributeType::Mixed;
     // Any additional server info to include.
     $attributes['serverInfo'] = AttributeType::Mixed;
     // The context of the request. Either 'craft' or a plugin handle.
     $attributes['handle'] = array(AttributeType::String, 'default' => 'craft', 'required' => true);
     return $attributes;
 }
开发者ID:floodhelpers,项目名称:floodhelpers,代码行数:51,代码来源:EtModel.php

示例4: defineAttributes

 /**
  * @access protected
  * @return array
  */
 protected function defineAttributes()
 {
     // The client license key.
     $attributes['licenseKey'] = AttributeType::String;
     // The license key status.  Set by the server response.
     $attributes['licenseKeyStatus'] = AttributeType::String;
     // The domain that the license is associated with
     $attributes['licensedDomain'] = AttributeType::String;
     // Extra arbitrary data to send to the server.
     $attributes['data'] = AttributeType::Mixed;
     // The url making the request.
     $attributes['requestUrl'] = array(AttributeType::String, 'default' => '');
     // The IP address making the request.
     $attributes['requestIp'] = array(AttributeType::String, 'default' => '1.1.1.1');
     // The time the request was made.
     $attributes['requestTime'] = array(AttributeType::DateTime, 'default' => DateTimeHelper::currentTimeForDb());
     // The port number the request comes from.
     $attributes['requestPort'] = AttributeType::String;
     // Any packages installed on the client.
     $attributes['installedPackages'] = array(AttributeType::Mixed, 'default' => array());
     // All the packages that are actually licensed.
     $attributes['licensedPackages'] = array(AttributeType::Mixed, 'default' => array());
     // Any packages that are in trial mode.
     $attributes['packageTrials'] = array(AttributeType::Mixed, 'default' => array());
     // The local version number.
     $attributes['localVersion'] = array(AttributeType::String, 'required' => true);
     // The local build number.
     $attributes['localBuild'] = array(AttributeType::Number, 'required' => true);
     // The currently logged in user's email address.
     $attributes['userEmail'] = AttributeType::String;
     // The track this install is on.  Not required for backwards compatibility.
     $attributes['track'] = array(AttributeType::String);
     // Any errors to return;
     $attributes['errors'] = AttributeType::Mixed;
     return $attributes;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:40,代码来源:EtModel.php

示例5: deleteExpiredCaches

 /**
  * Deletes any expired caches.
  *
  * @return bool
  */
 public function deleteExpiredCaches()
 {
     if ($this->_deletedAllCaches || $this->_deletedExpiredCaches) {
         return false;
     }
     $affectedRows = craft()->db->createCommand()->delete(static::$_templateCachesTable, 'expiryDate <= :now', array('now' => DateTimeHelper::currentTimeForDb()));
     $this->_deletedExpiredCaches = true;
     return (bool) $affectedRows;
 }
开发者ID:webremote,项目名称:craft_boilerplate,代码行数:14,代码来源:TemplateCacheService.php

示例6: getElementQueryStatusCondition

 /**
  * @inheritDoc IElementType::getElementQueryStatusCondition()
  *
  * @param DbCommand $query
  * @param string    $status
  *
  * @return array|false|string|void
  */
 public function getElementQueryStatusCondition(DbCommand $query, $status)
 {
     $currentTimeDb = DateTimeHelper::currentTimeForDb();
     switch ($status) {
         case EntryModel::LIVE:
             return array('and', 'elements.enabled = 1', 'elements_i18n.enabled = 1', "entries.postDate <= '{$currentTimeDb}'", array('or', 'entries.expiryDate is null', "entries.expiryDate > '{$currentTimeDb}'"));
         case EntryModel::PENDING:
             return array('and', 'elements.enabled = 1', 'elements_i18n.enabled = 1', "entries.postDate > '{$currentTimeDb}'");
         case EntryModel::EXPIRED:
             return array('and', 'elements.enabled = 1', 'elements_i18n.enabled = 1', 'entries.expiryDate is not null', "entries.expiryDate <= '{$currentTimeDb}'");
     }
 }
开发者ID:paulcarvill,项目名称:Convergence-craft,代码行数:20,代码来源:EntryElementType.php

示例7: update

 /**
  * @param string $table
  * @param array  $columns
  * @param mixed  $conditions
  * @param array  $params
  * @param bool   $includeAuditColumns
  *
  * @return int
  */
 public function update($table, $columns, $conditions = '', $params = array(), $includeAuditColumns = true)
 {
     $table = $this->getConnection()->addTablePrefix($table);
     $conditions = $this->_normalizeConditions($conditions, $params);
     if ($includeAuditColumns) {
         $columns['dateUpdated'] = DateTimeHelper::currentTimeForDb();
     }
     return parent::update($table, $columns, $conditions, $params);
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:18,代码来源:DbCommand.php

示例8: defineAttributes

 /**
  * Defines this model's attributes.
  *
  * @return array
  */
 protected function defineAttributes()
 {
     return array_merge(parent::defineAttributes(), array('redirectSrcUrl' => array(AttributeType::String, 'default' => ''), 'referrerUrl' => array(AttributeType::String, 'default' => ''), 'hitCount' => array(AttributeType::Number, 'default' => 0), 'hitLastTime' => array(AttributeType::DateTime, 'default' => DateTimeHelper::currentTimeForDb()), 'handledByRetour' => array(AttributeType::Bool, 'default' => false)));
 }
开发者ID:nystudio107,项目名称:retour,代码行数:9,代码来源:Retour_StatsModel.php

示例9: deleteExpiredTokens

 /**
  * Deletes any expired tokens.
  *
  * @return bool
  */
 public function deleteExpiredTokens()
 {
     // Ignore if we've already done this once during the request
     if ($this->_deletedExpiredTokens) {
         return false;
     }
     $affectedRows = craft()->db->createCommand()->delete('tokens', 'expiryDate <= :now', array('now' => DateTimeHelper::currentTimeForDb()));
     $this->_deletedExpiredTokens = true;
     return (bool) $affectedRows;
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:15,代码来源:TokensService.php

示例10: installPlugin

 /**
  * Installs a plugin.
  *
  * @param $handle
  * @throws Exception
  * @throws \Exception
  * @return bool
  */
 public function installPlugin($handle)
 {
     $plugin = $this->getPlugin($handle, false);
     $lcPluginHandle = strtolower($plugin->getClassHandle());
     if (!$plugin) {
         $this->_noPluginExists($handle);
     }
     if ($plugin->isInstalled) {
         throw new Exception(Craft::t('“{plugin}” is already installed.', array('plugin' => $plugin->getName())));
     }
     $transaction = craft()->db->beginTransaction();
     try {
         // Add the plugins as a record to the database.
         craft()->db->createCommand()->insert('plugins', array('class' => $plugin->getClassHandle(), 'version' => $plugin->version, 'enabled' => true, 'installDate' => DateTimeHelper::currentTimeForDb()));
         $plugin->isInstalled = true;
         $plugin->isEnabled = true;
         $this->_enabledPlugins[$lcPluginHandle] = $plugin;
         $this->_importPluginComponents($plugin);
         $plugin->createTables();
         $transaction->commit();
     } catch (\Exception $e) {
         $transaction->rollBack();
         throw $e;
     }
     $plugin->onAfterInstall();
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:35,代码来源:PluginsService.php

示例11: incrementStatistics

 /**
  * @param  $url The 404 url
  */
 public function incrementStatistics($url, $handled = false)
 {
     $handled = (int) $handled;
     $url = substr($url, 0, 255);
     $referrer = craft()->request->getUrlReferrer();
     if (is_null($referrer)) {
         $referrer = "";
     }
     /* -- See if a stats record exists already */
     $result = craft()->db->createCommand()->select('*')->from('retour_stats')->where('redirectSrcUrl =' . craft()->db->quoteValue($url))->queryAll();
     if (empty($result)) {
         $stats = new Retour_StatsRecord();
         $stats->redirectSrcUrl = $url;
         $stats->referrerUrl = $referrer;
         $stats->hitCount = 1;
         $stats->hitLastTime = DateTimeHelper::currentUTCDateTime();
         $stats->handledByRetour = $handled;
         $stats->save();
     } else {
         /* -- Update the stats table */
         foreach ($result as $stat) {
             $stat['hitCount'] = $stat['hitCount'] + 1;
             $stat['hitLastTime'] = DateTimeHelper::currentTimeForDb();
             $stat['referrerUrl'] = $referrer;
             $result = craft()->db->createCommand()->update('retour_stats', array('hitCount' => $stat['hitCount'], 'hitLastTime' => $stat['hitLastTime'], 'handledByRetour' => $handled, 'referrerUrl' => $stat['referrerUrl']), 'id=:id', array(':id' => $stat['id']));
         }
     }
 }
开发者ID:nystudio107,项目名称:retour,代码行数:31,代码来源:RetourService.php

示例12: prepAttributesForSave

 /**
  * Prepares the model's attribute values to be saved to the database.
  *
  * @return null
  */
 public function prepAttributesForSave()
 {
     $attributes = $this->getAttributeConfigs();
     $attributes['dateUpdated'] = array('type' => AttributeType::DateTime, 'column' => ColumnType::DateTime, 'required' => true);
     $attributes['dateCreated'] = array('type' => AttributeType::DateTime, 'column' => ColumnType::DateTime, 'required' => true);
     foreach ($attributes as $name => $config) {
         $value = $this->getAttribute($name);
         if ($config['type'] == AttributeType::DateTime) {
             // Leaving this in because we want to allow plugin devs to save a timestamp or DateTime object.
             if (DateTimeHelper::isValidTimeStamp($value)) {
                 $value = new DateTime('@' . $value);
             }
         }
         $this->setAttribute($name, ModelHelper::packageAttributeValue($value, true));
     }
     // Populate dateCreated and uid if this is a new record
     if ($this->isNewRecord()) {
         $this->dateCreated = DateTimeHelper::currentTimeForDb();
         $this->uid = StringHelper::UUID();
     }
     // Update the dateUpdated
     $this->dateUpdated = DateTimeHelper::currentTimeForDb();
 }
开发者ID:vescoyez,项目名称:portfolio_v2,代码行数:28,代码来源:BaseRecord.php

示例13: migrateUp

 /**
  * @param      $class
  * @param null $plugin
  *
  * @return bool|null
  */
 public function migrateUp($class, $plugin = null)
 {
     if ($class === $this->getBaseMigration()) {
         return null;
     }
     if ($plugin) {
         Craft::log('Applying migration: ' . $class . ' for plugin: ' . $plugin->getClassHandle(), LogLevel::Info, true);
     } else {
         Craft::log('Applying migration: ' . $class, LogLevel::Info, true);
     }
     $start = microtime(true);
     $migration = $this->instantiateMigration($class, $plugin);
     if ($migration->up() !== false) {
         if ($plugin) {
             $pluginInfo = craft()->plugins->getPluginInfo($plugin);
             craft()->db->createCommand()->insert($this->_migrationTable, array('version' => $class, 'applyTime' => DateTimeHelper::currentTimeForDb(), 'pluginId' => $pluginInfo['id']));
         } else {
             craft()->db->createCommand()->insert($this->_migrationTable, array('version' => $class, 'applyTime' => DateTimeHelper::currentTimeForDb()));
         }
         $time = microtime(true) - $start;
         Craft::log('Applied migration: ' . $class . ' (time: ' . sprintf("%.3f", $time) . 's)', LogLevel::Info, true);
         return true;
     } else {
         $time = microtime(true) - $start;
         Craft::log('Failed to apply migration: ' . $class . ' (time: ' . sprintf("%.3f", $time) . 's)', LogLevel::Error);
         return false;
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:34,代码来源:MigrationsService.php

示例14: getElementQueryStatusCondition

 /**
  * @inheritDoc IElementType::getElementQueryStatusCondition()
  *
  * @param DbCommand $query
  * @param string    $status
  *
  * @return array|false|string|void
  */
 public function getElementQueryStatusCondition(DbCommand $query, $status)
 {
     $currentTimeDb = DateTimeHelper::currentTimeForDb();
     switch ($status) {
         case PushNotifications_NotificationModel::SENT:
             return array("or", "pushnotifications_notifications.schedule IS NULL", "pushnotifications_notifications.schedule <= '{$currentTimeDb}'");
             break;
         case PushNotifications_NotificationModel::PENDING:
             return "pushnotifications_notifications.schedule > '{$currentTimeDb}'";
             break;
     }
 }
开发者ID:webremote,项目名称:pushnotifications,代码行数:20,代码来源:PushNotifications_NotificationElementType.php

示例15: getElementQueryStatusCondition

 /**
  * @inheritDoc IElementType::getElementQueryStatusCondition()
  *
  * @param DbCommand $query
  * @param string    $status
  *
  * @return array|false|string|void
  */
 public function getElementQueryStatusCondition(DbCommand $query, $status)
 {
     $currentTimeDb = DateTimeHelper::currentTimeForDb();
     switch ($status) {
         case Market_ProductModel::LIVE:
             return ['and', 'elements.enabled = 1', 'elements_i18n.enabled = 1', "products.availableOn <= '{$currentTimeDb}'", ['or', 'products.expiresOn is null', "products.expiresOn > '{$currentTimeDb}'"]];
         case Market_ProductModel::PENDING:
             return ['and', 'elements.enabled = 1', 'elements_i18n.enabled = 1', "products.availableOn > '{$currentTimeDb}'"];
         case Market_ProductModel::EXPIRED:
             return ['and', 'elements.enabled = 1', 'elements_i18n.enabled = 1', 'products.expiresOn is not null', "products.expiresOn <= '{$currentTimeDb}'"];
     }
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:20,代码来源:Market_ProductElementType.php


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