當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。