本文整理汇总了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]]);
}
}