本文整理汇总了PHP中app\models\Property::getDb方法的典型用法代码示例。如果您正苦于以下问题:PHP Property::getDb方法的具体用法?PHP Property::getDb怎么用?PHP Property::getDb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Property
的用法示例。
在下文中一共展示了Property::getDb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareProperties
private function prepareProperties()
{
$props = Property::getDb()->cache(function ($db) {
return Property::find()->select('id, name, property_handler_id, key, property_group_id, has_static_values, is_eav, handler_additional_params')->all();
}, 86400, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Property::className())]]));
foreach ($props as $one) {
$additionalParams = Json::decode($one['handler_additional_params']);
if (false === empty($additionalParams['use_in_file'])) {
if (1 == $one['is_eav'] && false === isset(self::$ymlEavProperties[$one['id']])) {
self::$ymlEavProperties[$one['id']] = ['name' => $one['name'], 'unit' => empty($additionalParams['unit']) ? '' : $additionalParams['unit'], 'key' => $one['key'], 'group_id' => $one['property_group_id'], 'handler_id' => $one['property_handler_id']];
} else {
if (1 == $one['has_static_values'] && false === isset(self::$ymlStaticProperties[$one['id']])) {
self::$ymlStaticProperties[$one['id']] = ['name' => $one['name'], 'unit' => empty($additionalParams['unit']) ? '' : $additionalParams['unit']];
}
}
}
}
}
示例2: isset
/*
* As you can see this is just a simple yii2 view file with several additional variables available
*
* For content rendering use $this->blocks!
*/
/**
* @var \app\components\WebView $this
* @var $breadcrumbs array
* @var $model \app\modules\page\models\Page
*/
$this->params['breadcrumbs'] = $breadcrumbs;
use yii\helpers\Html;
// we need id of property that is related to todays-deals
// in production it is better to fill it statically in your template for better performance
$propertyId = \app\models\Property::getDb()->cache(function ($db) {
return \app\models\Property::find()->where(['key' => 'todays_deals'])->select('id')->scalar($db);
}, 86400, new \yii\caching\TagDependency(['tags' => [\devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag(\app\models\Property::className())]]));
?>
<div class="container rows-padding-top-bottom-20">
<div class="row">
<div class="col-md-12">
<h1 class="text-center">
<?php
echo isset($this->blocks['h1']) ? $this->blocks['h1'] : Yii::t('app', 'Today\'s deals');
?>
</h1>
<!-- here we use ProductsWidget to show the same products as in Today's deal prefiltered page -->
<?php
if (intval($propertyId) > 0) {