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


PHP ActiveRecord::instantiate方法代码示例

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


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

示例1: instantiate

 /**
  * @see		ActiveRecord::instantiate()
  */
 public function instantiate($attributes)
 {
     $res = parent::instantiate($attributes);
     /*
      * We have to set some properties by hand
      */
     if (isset($attributes['COLUMN_TYPE'])) {
         // Size / scale
         if (DataType::check($attributes['COLUMN_TYPE'], DataType::SUPPORTS_SIZE)) {
             if (preg_match('/^\\w+\\((\\d+)(,\\d+)?\\)/', $attributes['COLUMN_TYPE'], $result)) {
                 $res->size = (int) $result[1];
                 if (isset($result[2]) && DataType::check($attributes['COLUMN_TYPE'], DataType::SUPPORTS_SCALE)) {
                     $res->scale = (int) substr($result[2], 1);
                 }
             }
         } elseif (DataType::check($attributes['COLUMN_TYPE'], DataType::SUPPORTS_VALUES)) {
             if (preg_match('/^\\w+\\(\'([^\\)]+)\'\\)/', $attributes['COLUMN_TYPE'], $result)) {
                 $res->setValues(implode("\n", (array) explode("','", $result[1])));
             }
         }
         // Unsigned
         if (preg_match('/ unsigned$/', $attributes['COLUMN_TYPE'])) {
             $res->attribute = 'unsigned';
         } elseif (preg_match('/ unsigned zerofill$/', $attributes['COLUMN_TYPE'])) {
             $res->attribute = 'unsigned zerofill';
         } elseif ($attributes['COLUMN_TYPE'] == 'timestamp') {
             if (strtolower($attributes['EXTRA']) == 'on update current_timestamp') {
                 $res->attribute = 'on update current_timestamp';
             }
         }
     }
     return $res;
 }
开发者ID:cebe,项目名称:chive,代码行数:36,代码来源:Column.php

示例2: instantiate

 /**
  * @see		ActiveRecord::instantiate()
  */
 public function instantiate($attributes)
 {
     $res = parent::instantiate($attributes);
     $res->table = Table::model()->findByAttributes(array('TABLE_SCHEMA' => $attributes['TABLE_SCHEMA'], 'TABLE_NAME' => $attributes['TABLE_NAME']));
     $match = '/^\\s+constraint `' . $attributes['CONSTRAINT_NAME'] . '` .+?$/im';
     if (preg_match($match, $res->table->getShowCreateTable(), $result)) {
         if (preg_match('/on delete (CASCADE|NO ACTION|SET NULL|RESTRICT)/i', $result[0], $result2)) {
             $res->onDelete = $result2[1];
         }
         if (preg_match('/on update (CASCADE|NO ACTION|SET NULL|RESTRICT)/i', $result[0], $result2)) {
             $res->onUpdate = $result2[1];
         }
     }
     return $res;
 }
开发者ID:cebe,项目名称:chive,代码行数:18,代码来源:ForeignKey.php

示例3: instantiate

 /**
  * @see		ActiveRecord::instantiate()
  */
 public function instantiate($attributes)
 {
     $res = parent::instantiate($attributes);
     // Check options
     if (isset($attributes['CREATE_OPTIONS'])) {
         $options = strtolower($attributes['CREATE_OPTIONS']);
     } else {
         $options = null;
     }
     if (strpos($options, 'checksum=1') !== false) {
         $res->optionChecksum = $res->originalOptionChecksum = '1';
     }
     if (strpos($options, 'delay_key_write=1') !== false) {
         $res->optionDelayKeyWrite = $res->originalOptionDelayKeyWrite = '1';
     }
     if (strpos($options, 'pack_keys=1') !== false) {
         $res->optionPackKeys = $res->originalOptionPackKeys = '1';
     } elseif (strpos($options, 'pack_keys=0') !== false) {
         $res->optionPackKeys = $res->originalOptionPackKeys = '0';
     }
     // Comment
     if (isset($attributes['TABLE_COMMENT'])) {
         if (isset($attributes['ENGINE']) && $attributes['ENGINE'] == 'InnoDB') {
             $search = 'InnoDB free: \\d+ ..?$';
             if (preg_match('/^' . $search . '/', $attributes['TABLE_COMMENT'])) {
                 $res->comment = '';
             } elseif (preg_match('/; ' . $search . '/', $attributes['TABLE_COMMENT'], $result)) {
                 $res->comment = str_replace($result[0], '', $attributes['TABLE_COMMENT']);
             } else {
                 $res->comment = $attributes['TABLE_COMMENT'];
             }
         } else {
             $res->comment = $attributes['TABLE_COMMENT'];
         }
     }
     $res->originalAttributes['comment'] = $res->comment;
     return $res;
 }
开发者ID:cebe,项目名称:chive,代码行数:41,代码来源:Table.php


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