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


PHP ActiveRecord::hasOne方法代码示例

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


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

示例1: getMetaRelation

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMetaRelation()
 {
     $query = $this->owner->hasOne($this->metaClass, ['entity_id' => 'id']);
     if ($this->ownerType) {
         $query->where(['entity_type' => $this->ownerType]);
     }
     return $query;
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:11,代码来源:SeoBehavior.php

示例2: getTranslation

 /**
  * Relation to model translation
  *
  * @param $language
  *
  * @return ActiveQuery
  * @since 2.0.0
  */
 public function getTranslation($language = null)
 {
     if ($language == null) {
         $language = $this->currentLanguage;
     }
     return $this->owner->hasOne($this->translateClassName, [$this->translateForeignKey => $this->ownerPrimaryKey])->where([$this->languageField => $language]);
 }
开发者ID:navatech,项目名称:yii2-multi-language,代码行数:15,代码来源:LanguageBehavior.php

示例3: hasOne

 public function hasOne($class, $link, $alias = null)
 {
     $query = parent::hasOne($class, $link);
     if ($alias == null) {
         $alias = lcfirst(str_replace('_', '', $class::tableName()));
     }
     return $query->from([$alias => $class::tableName()]);
 }
开发者ID:harryzheng0907,项目名称:yii2-rest,代码行数:8,代码来源:ActiveRecord.php

示例4: getSeo

 public function getSeo()
 {
     return $this->owner->hasOne(SeoText::className(), ['item_id' => $this->owner->primaryKey()[0]])->where(['class' => $this->owner->className()]);
 }
开发者ID:nanodesu88,项目名称:easyii,代码行数:4,代码来源:SeoBehavior.php

示例5: getTranslation

 /**
  * Relation to model translation
  *
  * @param $locale
  * @return ActiveQuery
  */
 public function getTranslation($locale = null)
 {
     $locale = $locale ?: Yii::$app->language;
     return $this->owner->hasOne($this->translationModelName, [$this->translationOwnerField => $this->ownerPrimaryKey])->from(['content' => call_user_func([$this->translationModelName, 'tableName'])])->innerJoin(['lang' => Language::tableName()])->where('lang.locale = :locale', [':locale' => $locale])->andWhere('content.' . $this->owner->getDb()->quoteColumnName($this->languageField) . ' = lang.id');
 }
开发者ID:gbksoft,项目名称:yii2-multilingual,代码行数:11,代码来源:Multilingual.php

示例6: getFile

 /**
  * @return File\Query
  */
 public function getFile()
 {
     return $this->owner->hasOne(File::className(), ['id' => $this->attribute]);
 }
开发者ID:stee1cat,项目名称:yii2-file-attachment,代码行数:7,代码来源:FileBehavior.php

示例7: hasOne

 /**
  * @inheritdoc
  */
 public function hasOne($class, $link)
 {
     return parent::hasOne($this->replaceRelatedClass($class), $link);
 }
开发者ID:tsyrya,项目名称:mybriop,代码行数:7,代码来源:ActiveRecord.php

示例8: hasOne

 public function hasOne($class, $link)
 {
     $rclass = $this->replaceClassWithCurrentPathOne($class);
     return parent::hasOne($rclass, $link);
 }
开发者ID:dawei101,项目名称:plants,代码行数:5,代码来源:ActiveRecord.php


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