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


PHP fORM::replicate方法代码示例

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


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

示例1: __clone

 /**
  * Creates a clone of a record
  * 
  * If the record has an auto incrementing primary key, the primary key will
  * be erased in the clone. If the primary key is not auto incrementing,
  * the primary key will be left as-is in the clone. In either situation the
  * clone will return `FALSE` from the ::exists() method until ::store() is
  * called.
  * 
  * @internal
  * 
  * @return fActiveRecord
  */
 public function __clone()
 {
     $class = get_class($this);
     // Copy values and cache, making sure objects are cloned to prevent reference issues
     $temp_values = $this->values;
     $new_values = array();
     $this->values =& $new_values;
     foreach ($temp_values as $column => $value) {
         $this->values[$column] = fORM::replicate($class, $column, $value);
     }
     $temp_cache = $this->cache;
     $new_cache = array();
     $this->cache =& $new_cache;
     foreach ($temp_cache as $key => $value) {
         if (is_object($value)) {
             $this->cache[$key] = clone $value;
         } else {
             $this->cache[$key] = $value;
         }
     }
     // Related records are purged
     $new_related_records = array();
     $this->related_records =& $new_related_records;
     // Old values are changed to look like the record is non-existant
     $new_old_values = array();
     $this->old_values =& $new_old_values;
     foreach (array_keys($this->values) as $key) {
         $this->old_values[$key] = array(NULL);
     }
     // If we have a single auto incrementing primary key, remove the value
     $schema = fORMSchema::retrieve($class);
     $table = fORM::tablize($class);
     $pk_columns = $schema->getKeys($table, 'primary');
     if (sizeof($pk_columns) == 1 && $schema->getColumnInfo($table, $pk_columns[0], 'auto_increment')) {
         $this->values[$pk_columns[0]] = NULL;
         unset($this->old_values[$pk_columns[0]]);
     }
 }
开发者ID:mrjwc,项目名称:printmaster,代码行数:51,代码来源:fActiveRecord.php


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