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


PHP ActiveRecord::__set方法代码示例

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


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

示例1: __set

 public function __set($name, $value)
 {
     if (in_array($name, $this->i18n())) {
         $attr = Yii::app()->language . '_' . $name;
         $this->{$attr} = $value;
     } else {
         parent::__set($name, $value);
     }
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:9,代码来源:I18nActiveRecord.php

示例2: __set

 /**
  * Magic method for setting properties.
  */
 public function __set($name, $value)
 {
     switch ($name) {
         case 'name':
             $value = trim($value);
             if (strlen($value) < self::MIN_USERNAME_LENGTH) {
                 // Usage of strlen() intentional for unicode characters
                 throw new ErrorException('Username should be at least ' . self::MIN_USERNAME_LENGTH . ' characters.');
             }
             if (mb_strlen($value) > self::MAX_USERNAME_LENGTH) {
                 throw new ErrorException('Username may not exceed ' . self::MAX_USERNAME_LENGTH . ' characters.');
             }
             if (SessionUser::IllegalUsername($value)) {
                 throw new ErrorException('Username is reserved. Please choose another username.');
             }
             try {
                 $class = get_called_class();
                 $user = $class::FindByName($value);
                 throw new ErrorException('Username already exists. Please choose another username.');
             } catch (ActiveRecord_NotFoundException $e) {
                 // "Not Found" is the desired result
             }
             parent::__set($name, $value);
             break;
         case 'password':
             throw new ErrorException('Use <i>SetPassword()</i> to change password.');
         case 'email':
             if (!empty($value)) {
                 $value = filter_var($value, FILTER_VALIDATE_EMAIL);
                 if ($value == false) {
                     throw new ErrorException('Email address is not valid. Please check if you entered it correctly.');
                 }
                 // Check if email host actually exists (parse_url() is faked into thinking email address is URL to get hostname)
                 $parts = parse_url('http://' . $value . '/');
                 if (!isset($parts['host']) || filter_var($parts['host'], FILTER_VALIDATE_IP) == false && gethostbyname($parts['host']) == $parts['host']) {
                     throw new ErrorException('Your email host <i>' . SafeHTML($parts['host']) . '</i> does not appear to exist.');
                 }
                 parent::__set($name, $value);
             }
             break;
         default:
             parent::__set($name, $value);
     }
 }
开发者ID:Strikethegod,项目名称:fanzub,代码行数:47,代码来源:class.session.php

示例3: __set

 /**
  * Запрет менять type
  * 
  * @param type $name
  * @param type $value
  * @throws Exception 
  */
 public function __set($name, $value)
 {
     if ($name == 'type') {
         throw new Exception('Запрещено менять тип записей');
     } else {
         parent::__set($name, $value);
     }
 }
开发者ID:ruyozora,项目名称:Test-test,代码行数:15,代码来源:Store.php

示例4: __set

 /**
  * Magic method for setting properties.
  */
 public function __set($name, $value)
 {
     switch ($name) {
         case 'post_date':
             if ($value > time()) {
                 $this->changes[$name] = time();
             } else {
                 $this->changes[$name] = $value;
             }
             break;
         default:
             parent::__set($name, $value);
     }
 }
开发者ID:Strikethegod,项目名称:fanzub,代码行数:17,代码来源:class.fanzub.php


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