mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-12 20:49:50 +00:00
Fixing bug for related records not being returned when using $recursive > 1.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5902 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
28d6ef1688
commit
8d6599c34b
19 changed files with 492 additions and 359 deletions
2
cake/libs/cache/model.php
vendored
2
cake/libs/cache/model.php
vendored
|
@ -94,7 +94,7 @@ class ModelEngine extends CacheEngine {
|
|||
return false;
|
||||
}
|
||||
|
||||
$cache = array($this->__Model->name => array(
|
||||
$cache = array($this->__Model->currentModel => array(
|
||||
$this->__fields[0] => $data,
|
||||
$this->__fields[1] => time() + $duration));
|
||||
|
||||
|
|
|
@ -297,14 +297,14 @@ class DB_ACL extends AclBase {
|
|||
$inherited = array();
|
||||
for ($i = 0 ; $i < count($aroPath); $i++) {
|
||||
$perms = $this->Aro->Permission->findAll(array(
|
||||
$this->Aro->Permission->name . '.aro_id' => $aroPath[$i][$this->Aro->name]['id'],
|
||||
$this->Aro->Permission->name . '.aco_id' => $acoPath->extract('{n}.' . $this->Aco->name . '.id')),
|
||||
null, array($this->Aco->name . '.lft' => 'desc'), null, null, 0);
|
||||
$this->Aro->Permission->currentModel . '.aro_id' => $aroPath[$i][$this->Aro->currentModel]['id'],
|
||||
$this->Aro->Permission->currentModel . '.aco_id' => $acoPath->extract('{n}.' . $this->Aco->currentModel . '.id')),
|
||||
null, array($this->Aco->currentModel . '.lft' => 'desc'), null, null, 0);
|
||||
|
||||
if (empty($perms)) {
|
||||
continue;
|
||||
} else {
|
||||
foreach (Set::extract($perms, '{n}.' . $this->Aro->Permission->name) as $perm) {
|
||||
foreach (Set::extract($perms, '{n}.' . $this->Aro->Permission->currentModel) as $perm) {
|
||||
if ($action == '*') {
|
||||
|
||||
foreach ($permKeys as $key) {
|
||||
|
@ -358,7 +358,7 @@ class DB_ACL extends AclBase {
|
|||
}
|
||||
|
||||
if (isset($perms[0])) {
|
||||
$save = $perms[0][$this->Aro->Permission->name];
|
||||
$save = $perms[0][$this->Aro->Permission->currentModel];
|
||||
}
|
||||
|
||||
if ($actions == "*") {
|
||||
|
@ -387,7 +387,7 @@ class DB_ACL extends AclBase {
|
|||
$save['aco_id'] = $perms['aco'];
|
||||
|
||||
if ($perms['link'] != null && count($perms['link']) > 0) {
|
||||
$save['id'] = $perms['link'][0][$this->Aro->Permission->name]['id'];
|
||||
$save['id'] = $perms['link'][0][$this->Aro->Permission->currentModel]['id'];
|
||||
}
|
||||
$this->Aro->Permission->create($save);
|
||||
return $this->Aro->Permission->save();
|
||||
|
@ -460,11 +460,11 @@ class DB_ACL extends AclBase {
|
|||
}
|
||||
|
||||
return array(
|
||||
'aro' => Set::extract($obj, 'Aro.0.'.$this->Aro->name.'.id'),
|
||||
'aco' => Set::extract($obj, 'Aco.0.'.$this->Aco->name.'.id'),
|
||||
'aro' => Set::extract($obj, 'Aro.0.'.$this->Aro->currentModel.'.id'),
|
||||
'aco' => Set::extract($obj, 'Aco.0.'.$this->Aco->currentModel.'.id'),
|
||||
'link' => $this->Aro->Permission->findAll(array(
|
||||
$this->Aro->Permission->name . '.aro_id' => Set::extract($obj, 'Aro.0.'.$this->Aro->name.'.id'),
|
||||
$this->Aro->Permission->name . '.aco_id' => Set::extract($obj, 'Aco.0.'.$this->Aco->name.'.id')
|
||||
$this->Aro->Permission->currentModel . '.aro_id' => Set::extract($obj, 'Aro.0.'.$this->Aro->currentModel.'.id'),
|
||||
$this->Aro->Permission->currentModel . '.aco_id' => Set::extract($obj, 'Aco.0.'.$this->Aco->currentModel.'.id')
|
||||
))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -595,8 +595,8 @@ class Controller extends Object {
|
|||
|
||||
$errors = array();
|
||||
foreach ($objects as $object) {
|
||||
$this->{$object->name}->set($object->data);
|
||||
$errors = array_merge($errors, $this->{$object->name}->invalidFields());
|
||||
$this->{$object->currentModel}->set($object->data);
|
||||
$errors = array_merge($errors, $this->{$object->currentModel}->invalidFields());
|
||||
}
|
||||
return $this->validationErrors = (count($errors) ? $errors : false);
|
||||
}
|
||||
|
@ -1098,8 +1098,8 @@ class Controller extends Object {
|
|||
return array();
|
||||
}
|
||||
$options = am($this->params, $this->params['url'], $this->passedArgs);
|
||||
if (isset($this->paginate[$object->name])) {
|
||||
$defaults = $this->paginate[$object->name];
|
||||
if (isset($this->paginate[$object->currentModel])) {
|
||||
$defaults = $this->paginate[$object->currentModel];
|
||||
} else {
|
||||
$defaults = $this->paginate;
|
||||
}
|
||||
|
@ -1117,7 +1117,7 @@ class Controller extends Object {
|
|||
if (!empty($options['order']) && is_array($options['order'])) {
|
||||
$key = key($options['order']);
|
||||
if (strpos($key, '.') === false && $object->hasField($key)) {
|
||||
$options['order'][$object->name . '.' . $key] = $options['order'][$key];
|
||||
$options['order'][$object->currentModel . '.' . $key] = $options['order'][$key];
|
||||
unset($options['order'][$key]);
|
||||
}
|
||||
}
|
||||
|
@ -1177,7 +1177,7 @@ class Controller extends Object {
|
|||
'options' => $options
|
||||
);
|
||||
|
||||
$this->params['paging'][$object->name] = $paging;
|
||||
$this->params['paging'][$object->currentModel] = $paging;
|
||||
|
||||
if (!in_array('Paginator', $this->helpers) && !array_key_exists('Paginator', $this->helpers)) {
|
||||
$this->helpers[] = 'Paginator';
|
||||
|
|
|
@ -52,8 +52,8 @@ class AclBehavior extends ModelBehavior {
|
|||
if (is_string($config)) {
|
||||
$config = array('type' => $config);
|
||||
}
|
||||
$this->settings[$model->name] = am(array('type' => 'requester'), $config);
|
||||
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
$this->settings[$model->currentModel] = am(array('type' => 'requester'), $config);
|
||||
$type = $this->__typeMaps[$this->settings[$model->currentModel]['type']];
|
||||
|
||||
if (!ClassRegistry::isKeySet($type)) {
|
||||
uses('model' . DS . 'db_acl');
|
||||
|
@ -63,7 +63,7 @@ class AclBehavior extends ModelBehavior {
|
|||
}
|
||||
$model->{$type} =& $object;
|
||||
if (!method_exists($model, 'parentNode')) {
|
||||
trigger_error("Callback parentNode() not defined in {$model->name}", E_USER_WARNING);
|
||||
trigger_error("Callback parentNode() not defined in {$model->currentModel}", E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -73,9 +73,9 @@ class AclBehavior extends ModelBehavior {
|
|||
* @return array
|
||||
*/
|
||||
function node(&$model, $ref = null) {
|
||||
$type = $this->__typeMaps[low($this->settings[$model->name]['type'])];
|
||||
$type = $this->__typeMaps[low($this->settings[$model->currentModel]['type'])];
|
||||
if (empty($ref)) {
|
||||
$ref = array('model' => $model->name, 'foreign_key' => $model->id);
|
||||
$ref = array('model' => $model->currentModel, 'foreign_key' => $model->id);
|
||||
}
|
||||
return $model->{$type}->node($ref);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class AclBehavior extends ModelBehavior {
|
|||
*/
|
||||
function afterSave(&$model, $created) {
|
||||
if ($created) {
|
||||
$type = $this->__typeMaps[low($this->settings[$model->name]['type'])];
|
||||
$type = $this->__typeMaps[low($this->settings[$model->currentModel]['type'])];
|
||||
$parent = $model->parentNode();
|
||||
if (!empty($parent)) {
|
||||
$parent = $this->node($model, $parent);
|
||||
|
@ -97,7 +97,7 @@ class AclBehavior extends ModelBehavior {
|
|||
$model->{$type}->create();
|
||||
$model->{$type}->save(array(
|
||||
'parent_id' => Set::extract($parent, "0.{$type}.id"),
|
||||
'model' => $model->name,
|
||||
'model' => $model->currentModel,
|
||||
'foreign_key' => $model->id
|
||||
));
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class AclBehavior extends ModelBehavior {
|
|||
*
|
||||
*/
|
||||
function afterDelete(&$model) {
|
||||
$type = $this->__typeMaps[low($this->settings[$model->name]['type'])];
|
||||
$type = $this->__typeMaps[low($this->settings[$model->currentModel]['type'])];
|
||||
$node = Set::extract($this->node($model), "0.{$type}.id");
|
||||
if (!empty($node)) {
|
||||
$model->{$type}->delete($node);
|
||||
|
|
|
@ -55,12 +55,12 @@ class TranslateBehavior extends ModelBehavior {
|
|||
function setup(&$model, $config = array()) {
|
||||
$db =& ConnectionManager::getDataSource($model->useDbConfig);
|
||||
if (!$db->connected) {
|
||||
trigger_error('Datasource '.$model->useDbConfig.' for TranslateBehavior of model '.$model->name.' is not connected', E_USER_ERROR);
|
||||
trigger_error('Datasource '.$model->useDbConfig.' for TranslateBehavior of model '.$model->currentModel.' is not connected', E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->settings[$model->name] = array();
|
||||
$this->runtime[$model->name] = array('fields' => array());
|
||||
$this->settings[$model->currentModel] = array();
|
||||
$this->runtime[$model->currentModel] = array('fields' => array());
|
||||
$this->translateModel($model);
|
||||
return $this->bindTranslation($model, null, false);
|
||||
}
|
||||
|
@ -74,20 +74,20 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$RuntimeModel =& $this->translateModel($model);
|
||||
|
||||
if (is_string($query['fields']) && 'COUNT(*) AS '.$db->name('count') == $query['fields']) {
|
||||
$this->runtime[$model->name]['count'] = true;
|
||||
$this->runtime[$model->currentModel]['count'] = true;
|
||||
|
||||
if (empty($locale)) {
|
||||
return $query;
|
||||
}
|
||||
$query['fields'] = 'COUNT(DISTINCT('.$db->name($model->name).'.'.$db->name($model->primaryKey).')) ' . $db->alias . 'count';
|
||||
$query['fields'] = 'COUNT(DISTINCT('.$db->name($model->currentModel).'.'.$db->name($model->primaryKey).')) ' . $db->alias . 'count';
|
||||
$query['joins'][] = array(
|
||||
'type' => 'INNER',
|
||||
'alias' => $RuntimeModel->name,
|
||||
'alias' => $RuntimeModel->currentModel,
|
||||
'table' => $db->name($tablePrefix . 'i18n'),
|
||||
'conditions' => array(
|
||||
$model->name.'.id' => '{$__cakeIdentifier['.$RuntimeModel->name.'.foreign_key]__$}',
|
||||
$RuntimeModel->name.'.model' => $model->name,
|
||||
$RuntimeModel->name.'.locale' => $locale));
|
||||
$model->currentModel.'.id' => '{$__cakeIdentifier['.$RuntimeModel->currentModel.'.foreign_key]__$}',
|
||||
$RuntimeModel->currentModel.'.model' => $model->currentModel,
|
||||
$RuntimeModel->currentModel.'.locale' => $locale));
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$autoFields = false;
|
||||
|
||||
if (empty($query['fields'])) {
|
||||
$query['fields'] = array($model->name.'.*');
|
||||
$query['fields'] = array($model->currentModel.'.*');
|
||||
|
||||
foreach (array('hasOne', 'belongsTo') as $type) {
|
||||
foreach ($model->{$type} as $key => $value) {
|
||||
|
@ -113,13 +113,13 @@ class TranslateBehavior extends ModelBehavior {
|
|||
}
|
||||
$autoFields = true;
|
||||
}
|
||||
$fields = am($this->settings[$model->name], $this->runtime[$model->name]['fields']);
|
||||
$fields = am($this->settings[$model->currentModel], $this->runtime[$model->currentModel]['fields']);
|
||||
$addFields = array();
|
||||
if (is_array($query['fields'])) {
|
||||
foreach ($fields as $key => $value) {
|
||||
$field = ife(is_numeric($key), $value, $key);
|
||||
|
||||
if (in_array($model->name.'.*', $query['fields']) || $autoFields || in_array($model->name.'.'.$field, $query['fields']) || in_array($field, $query['fields'])) {
|
||||
if (in_array($model->currentModel.'.*', $query['fields']) || $autoFields || in_array($model->currentModel.'.'.$field, $query['fields']) || in_array($field, $query['fields'])) {
|
||||
$addFields[] = $field;
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
|
||||
if ($addFields) {
|
||||
foreach ($addFields as $field) {
|
||||
foreach (array($field, $model->name.'.'.$field) as $_field) {
|
||||
foreach (array($field, $model->currentModel.'.'.$field) as $_field) {
|
||||
$key = array_search($_field, $query['fields']);
|
||||
|
||||
if ($key !== false) {
|
||||
|
@ -143,8 +143,8 @@ class TranslateBehavior extends ModelBehavior {
|
|||
'alias' => 'I18n__'.$field.'__'.$_locale,
|
||||
'table' => $db->name($tablePrefix . 'i18n'),
|
||||
'conditions' => array(
|
||||
$model->name.'.id' => '{$__cakeIdentifier[I18n__'.$field.'__'.$_locale.'.foreign_key]__$}',
|
||||
'I18n__'.$field.'__'.$_locale.'.model' => $model->name,
|
||||
$model->currentModel.'.id' => '{$__cakeIdentifier[I18n__'.$field.'__'.$_locale.'.foreign_key]__$}',
|
||||
'I18n__'.$field.'__'.$_locale.'.model' => $model->currentModel,
|
||||
'I18n__'.$field.'__'.$_locale.'.'.$RuntimeModel->displayField => $field,
|
||||
'I18n__'.$field.'__'.$_locale.'.locale' => $_locale));
|
||||
}
|
||||
|
@ -155,47 +155,47 @@ class TranslateBehavior extends ModelBehavior {
|
|||
'alias' => 'I18n__'.$field,
|
||||
'table' => $db->name($tablePrefix . 'i18n'),
|
||||
'conditions' => array(
|
||||
$model->name.'.id' => '{$__cakeIdentifier[I18n__'.$field.'.foreign_key]__$}',
|
||||
'I18n__'.$field.'.model' => $model->name,
|
||||
$model->currentModel.'.id' => '{$__cakeIdentifier[I18n__'.$field.'.foreign_key]__$}',
|
||||
'I18n__'.$field.'.model' => $model->currentModel,
|
||||
'I18n__'.$field.'.'.$RuntimeModel->displayField => $field));
|
||||
$query['conditions'][$db->name('I18n__'.$field.'.locale')] = $locale;
|
||||
}
|
||||
}
|
||||
}
|
||||
$query['fields'] = am($query['fields']);
|
||||
$this->runtime[$model->name]['beforeFind'] = $addFields;
|
||||
$this->runtime[$model->currentModel]['beforeFind'] = $addFields;
|
||||
return $query;
|
||||
}
|
||||
/**
|
||||
* Callback
|
||||
*/
|
||||
function afterFind(&$model, $results, $primary) {
|
||||
$this->runtime[$model->name]['fields'] = array();
|
||||
$this->runtime[$model->currentModel]['fields'] = array();
|
||||
$locale = $this->_getLocale($model);
|
||||
|
||||
if (empty($locale) || empty($results) || empty($this->runtime[$model->name]['beforeFind'])) {
|
||||
if (empty($locale) || empty($results) || empty($this->runtime[$model->currentModel]['beforeFind'])) {
|
||||
return $results;
|
||||
}
|
||||
$beforeFind = $this->runtime[$model->name]['beforeFind'];
|
||||
$beforeFind = $this->runtime[$model->currentModel]['beforeFind'];
|
||||
|
||||
foreach ($results as $key => $row) {
|
||||
$results[$key][$model->name]['locale'] = ife(is_array($locale), @$locale[0], $locale);
|
||||
$results[$key][$model->currentModel]['locale'] = ife(is_array($locale), @$locale[0], $locale);
|
||||
|
||||
foreach ($beforeFind as $field) {
|
||||
if (is_array($locale)) {
|
||||
foreach ($locale as $_locale) {
|
||||
if (!isset($results[$key][$model->name][$field]) && !empty($results[$key]['I18n__'.$field.'__'.$_locale]['content'])) {
|
||||
$results[$key][$model->name][$field] = $results[$key]['I18n__'.$field.'__'.$_locale]['content'];
|
||||
if (!isset($results[$key][$model->currentModel][$field]) && !empty($results[$key]['I18n__'.$field.'__'.$_locale]['content'])) {
|
||||
$results[$key][$model->currentModel][$field] = $results[$key]['I18n__'.$field.'__'.$_locale]['content'];
|
||||
}
|
||||
unset($results[$key]['I18n__'.$field.'__'.$_locale]);
|
||||
}
|
||||
|
||||
if (!isset($results[$key][$model->name][$field])) {
|
||||
$results[$key][$model->name][$field] = '';
|
||||
if (!isset($results[$key][$model->currentModel][$field])) {
|
||||
$results[$key][$model->currentModel][$field] = '';
|
||||
}
|
||||
} else {
|
||||
$value = ife(empty($results[$key]['I18n__'.$field]['content']), '', $results[$key]['I18n__'.$field]['content']);
|
||||
$results[$key][$model->name][$field] = $value;
|
||||
$results[$key][$model->currentModel][$field] = $value;
|
||||
unset($results[$key]['I18n__'.$field]);
|
||||
}
|
||||
}
|
||||
|
@ -211,31 +211,31 @@ class TranslateBehavior extends ModelBehavior {
|
|||
if (empty($locale) || is_array($locale)) {
|
||||
return true;
|
||||
}
|
||||
$fields = am($this->settings[$model->name], $this->runtime[$model->name]['fields']);
|
||||
$fields = am($this->settings[$model->currentModel], $this->runtime[$model->currentModel]['fields']);
|
||||
$tempData = array();
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
$field = ife(is_numeric($key), $value, $key);
|
||||
|
||||
if (isset($model->data[$model->name][$field])) {
|
||||
$tempData[$field] = $model->data[$model->name][$field];
|
||||
unset($model->data[$model->name][$field]);
|
||||
if (isset($model->data[$model->currentModel][$field])) {
|
||||
$tempData[$field] = $model->data[$model->currentModel][$field];
|
||||
unset($model->data[$model->currentModel][$field]);
|
||||
}
|
||||
}
|
||||
$this->runtime[$model->name]['beforeSave'] = $tempData;
|
||||
$this->runtime[$model->currentModel]['beforeSave'] = $tempData;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Callback
|
||||
*/
|
||||
function afterSave(&$model, $created) {
|
||||
if (!isset($this->runtime[$model->name]['beforeSave'])) {
|
||||
if (!isset($this->runtime[$model->currentModel]['beforeSave'])) {
|
||||
return true;
|
||||
}
|
||||
$locale = $this->_getLocale($model);
|
||||
$tempData = $this->runtime[$model->name]['beforeSave'];
|
||||
unset($this->runtime[$model->name]['beforeSave']);
|
||||
$conditions = array('locale' => $locale, 'model' => $model->name, 'foreign_key' => $model->id);
|
||||
$tempData = $this->runtime[$model->currentModel]['beforeSave'];
|
||||
unset($this->runtime[$model->currentModel]['beforeSave']);
|
||||
$conditions = array('locale' => $locale, 'model' => $model->currentModel, 'foreign_key' => $model->id);
|
||||
$RuntimeModel =& $this->translateModel($model);
|
||||
|
||||
if (empty($created)) {
|
||||
|
@ -244,7 +244,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
if ($translations) {
|
||||
foreach ($translations as $id => $field) {
|
||||
$RuntimeModel->create();
|
||||
$RuntimeModel->save(array($RuntimeModel->name => array('id' => $id, 'content' => $tempData[$field])));
|
||||
$RuntimeModel->save(array($RuntimeModel->currentModel => array('id' => $id, 'content' => $tempData[$field])));
|
||||
unset($tempData[$field]);
|
||||
}
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
*/
|
||||
function afterDelete(&$model) {
|
||||
$RuntimeModel =& $this->translateModel($model);
|
||||
$conditions = array('model' => $model->name, 'foreign_key' => $model->id);
|
||||
$conditions = array('model' => $model->currentModel, 'foreign_key' => $model->id);
|
||||
$RuntimeModel->deleteAll($conditions);
|
||||
}
|
||||
/**
|
||||
|
@ -286,7 +286,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
* @return object
|
||||
*/
|
||||
function &translateModel(&$model) {
|
||||
if (!isset($this->runtime[$model->name]['model'])) {
|
||||
if (!isset($this->runtime[$model->currentModel]['model'])) {
|
||||
if (!isset($model->translateModel) || empty($model->translateModel)) {
|
||||
$className = 'I18nModel';
|
||||
} else {
|
||||
|
@ -298,21 +298,21 @@ class TranslateBehavior extends ModelBehavior {
|
|||
|
||||
if (ClassRegistry::isKeySet($className)) {
|
||||
if (PHP5) {
|
||||
$this->runtime[$model->name]['model'] = ClassRegistry::getObject($className);
|
||||
$this->runtime[$model->currentModel]['model'] = ClassRegistry::getObject($className);
|
||||
} else {
|
||||
$this->runtime[$model->name]['model'] =& ClassRegistry::getObject($className);
|
||||
$this->runtime[$model->currentModel]['model'] =& ClassRegistry::getObject($className);
|
||||
}
|
||||
} else {
|
||||
if (PHP5) {
|
||||
$this->runtime[$model->name]['model'] = new $className();
|
||||
$this->runtime[$model->currentModel]['model'] = new $className();
|
||||
} else {
|
||||
$this->runtime[$model->name]['model'] =& new $className();
|
||||
$this->runtime[$model->currentModel]['model'] =& new $className();
|
||||
}
|
||||
ClassRegistry::addObject($className, $this->runtime[$model->name]['model']);
|
||||
ClassRegistry::addObject($className, $this->runtime[$model->currentModel]['model']);
|
||||
ClassRegistry::map($className, $className);
|
||||
}
|
||||
}
|
||||
return $this->runtime[$model->name]['model'];
|
||||
return $this->runtime[$model->currentModel]['model'];
|
||||
}
|
||||
/**
|
||||
* Bind translation for fields, optionally with hasMany association for
|
||||
|
@ -333,7 +333,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
}
|
||||
$associations = array();
|
||||
$RuntimeModel =& $this->translateModel($model);
|
||||
$default = array('className' => $RuntimeModel->name, 'foreignKey' => 'foreign_key');
|
||||
$default = array('className' => $RuntimeModel->currentModel, 'foreignKey' => 'foreign_key');
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
if (is_numeric($key)) {
|
||||
|
@ -344,42 +344,42 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$association = $value;
|
||||
}
|
||||
|
||||
if (array_key_exists($field, $this->settings[$model->name])) {
|
||||
unset($this->settings[$model->name][$field]);
|
||||
if (array_key_exists($field, $this->settings[$model->currentModel])) {
|
||||
unset($this->settings[$model->currentModel][$field]);
|
||||
|
||||
} elseif (in_array($field, $this->settings[$model->name])) {
|
||||
$this->settings[$model->name] = am(array_diff_assoc($this->settings[$model->name], array($field)));
|
||||
} elseif (in_array($field, $this->settings[$model->currentModel])) {
|
||||
$this->settings[$model->currentModel] = am(array_diff_assoc($this->settings[$model->currentModel], array($field)));
|
||||
}
|
||||
|
||||
if (array_key_exists($field, $this->runtime[$model->name]['fields'])) {
|
||||
unset($this->runtime[$model->name]['fields'][$field]);
|
||||
if (array_key_exists($field, $this->runtime[$model->currentModel]['fields'])) {
|
||||
unset($this->runtime[$model->currentModel]['fields'][$field]);
|
||||
|
||||
} elseif (in_array($field, $this->runtime[$model->name]['fields'])) {
|
||||
$this->runtime[$model->name]['fields'] = am(array_diff_assoc($this->runtime[$model->name]['fields'], array($field)));
|
||||
} elseif (in_array($field, $this->runtime[$model->currentModel]['fields'])) {
|
||||
$this->runtime[$model->currentModel]['fields'] = am(array_diff_assoc($this->runtime[$model->currentModel]['fields'], array($field)));
|
||||
}
|
||||
|
||||
if (is_null($association)) {
|
||||
if ($reset) {
|
||||
$this->runtime[$model->name]['fields'][] = $field;
|
||||
$this->runtime[$model->currentModel]['fields'][] = $field;
|
||||
} else {
|
||||
$this->settings[$model->name][] = $field;
|
||||
$this->settings[$model->currentModel][] = $field;
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($reset) {
|
||||
$this->runtime[$model->name]['fields'][$field] = $association;
|
||||
$this->runtime[$model->currentModel]['fields'][$field] = $association;
|
||||
} else {
|
||||
$this->settings[$model->name][$field] = $association;
|
||||
$this->settings[$model->currentModel][$field] = $association;
|
||||
}
|
||||
|
||||
foreach (array('hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany') as $type) {
|
||||
if (isset($model->{$type}[$association]) || isset($model->__backAssociation[$type][$association])) {
|
||||
trigger_error('Association '.$association.' is already binded to model '.$model->name, E_USER_ERROR);
|
||||
trigger_error('Association '.$association.' is already binded to model '.$model->currentModel, E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$associations[$association] = am($default, array('conditions' => array(
|
||||
'model' => $model->name,
|
||||
'model' => $model->currentModel,
|
||||
$RuntimeModel->displayField => $field)));
|
||||
}
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$fields = array($fields);
|
||||
}
|
||||
$RuntimeModel =& $this->translateModel($model);
|
||||
$default = array('className' => $RuntimeModel->name, 'foreignKey' => 'foreign_key');
|
||||
$default = array('className' => $RuntimeModel->currentModel, 'foreignKey' => 'foreign_key');
|
||||
$associations = array();
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
|
@ -418,18 +418,18 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$association = $value;
|
||||
}
|
||||
|
||||
if (array_key_exists($field, $this->settings[$model->name])) {
|
||||
unset($this->settings[$model->name][$field]);
|
||||
if (array_key_exists($field, $this->settings[$model->currentModel])) {
|
||||
unset($this->settings[$model->currentModel][$field]);
|
||||
|
||||
} elseif (in_array($field, $this->settings[$model->name])) {
|
||||
$this->settings[$model->name] = am(array_diff_assoc($this->settings[$model->name], array($field)));
|
||||
} elseif (in_array($field, $this->settings[$model->currentModel])) {
|
||||
$this->settings[$model->currentModel] = am(array_diff_assoc($this->settings[$model->currentModel], array($field)));
|
||||
}
|
||||
|
||||
if (array_key_exists($field, $this->runtime[$model->name]['fields'])) {
|
||||
unset($this->runtime[$model->name]['fields'][$field]);
|
||||
if (array_key_exists($field, $this->runtime[$model->currentModel]['fields'])) {
|
||||
unset($this->runtime[$model->currentModel]['fields'][$field]);
|
||||
|
||||
} elseif (in_array($field, $this->runtime[$model->name]['fields'])) {
|
||||
$this->runtime[$model->name]['fields'] = am(array_diff_assoc($this->runtime[$model->name]['fields'], array($field)));
|
||||
} elseif (in_array($field, $this->runtime[$model->currentModel]['fields'])) {
|
||||
$this->runtime[$model->currentModel]['fields'] = am(array_diff_assoc($this->runtime[$model->currentModel]['fields'], array($field)));
|
||||
}
|
||||
|
||||
if (!is_null($association) && (isset($model->hasMany[$association]) || isset($model->__backAssociation['hasMany'][$association]))) {
|
||||
|
|
|
@ -52,7 +52,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
$parent =& $model->{$data['className']};
|
||||
$settings['scope'] = $model->escapeField($data['foreignKey']) . ' = ' . $parent->escapeField($parent->primaryKey, $settings['scope']);
|
||||
}*/
|
||||
$this->settings[$model->name] = $settings;
|
||||
$this->settings[$model->currentModel] = $settings;
|
||||
}
|
||||
/**
|
||||
* After save method. Called after all saves
|
||||
|
@ -65,17 +65,17 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
function afterSave(&$model, $created) {
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
if (!$enabled) {
|
||||
return true;
|
||||
}
|
||||
if ($created) {
|
||||
if ((isset($model->data[$model->name][$parent])) && $model->data[$model->name][$parent]) {
|
||||
return $this->_setParent($model, $model->data[$model->name][$parent]);
|
||||
if ((isset($model->data[$model->currentModel][$parent])) && $model->data[$model->currentModel][$parent]) {
|
||||
return $this->_setParent($model, $model->data[$model->currentModel][$parent]);
|
||||
}
|
||||
} elseif ($__parentChange) {
|
||||
$this->settings[$model->name]['__parentChange'] = false;
|
||||
return $this->_setParent($model, $model->data[$model->name][$parent]);
|
||||
$this->settings[$model->currentModel]['__parentChange'] = false;
|
||||
return $this->_setParent($model, $model->data[$model->currentModel][$parent]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -87,13 +87,13 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @return boolean true to continue, false to abort the delete
|
||||
*/
|
||||
function beforeDelete(&$model) {
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
|
||||
if (!$enabled) {
|
||||
return true;
|
||||
}
|
||||
list($name, $data)= array(
|
||||
$model->name,
|
||||
$model->currentModel,
|
||||
$model->read());
|
||||
$data= $data[$name];
|
||||
|
||||
|
@ -121,44 +121,44 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @return boolean true to continue, false to abort the save
|
||||
*/
|
||||
function beforeSave(&$model) {
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
|
||||
if (!$enabled) {
|
||||
return true;
|
||||
}
|
||||
if (isset($model->data[$model->name][$model->primaryKey])) {
|
||||
if ($model->data[$model->name][$model->primaryKey]) {
|
||||
if (isset($model->data[$model->currentModel][$model->primaryKey])) {
|
||||
if ($model->data[$model->currentModel][$model->primaryKey]) {
|
||||
if (!$model->id) {
|
||||
$model->id = $model->data[$model->name][$model->primaryKey];
|
||||
$model->id = $model->data[$model->currentModel][$model->primaryKey];
|
||||
}
|
||||
}
|
||||
unset ($model->data[$model->name][$model->primaryKey]);
|
||||
unset ($model->data[$model->currentModel][$model->primaryKey]);
|
||||
}
|
||||
|
||||
if (!$model->id) {
|
||||
if ((!isset($model->data[$model->name][$parent])) || (!$model->data[$model->name][$parent])) {
|
||||
if ((!isset($model->data[$model->currentModel][$parent])) || (!$model->data[$model->currentModel][$parent])) {
|
||||
$edge = $this->__getMax($model, $scope, $right);
|
||||
$model->data[$model->name][$left]= $edge +1;
|
||||
$model->data[$model->name][$right]= $edge +2;
|
||||
$model->data[$model->currentModel][$left]= $edge +1;
|
||||
$model->data[$model->currentModel][$right]= $edge +2;
|
||||
} else {
|
||||
$parentNode = $model->find(array($scope, $model->escapeField() => $model->data[$model->name][$parent]),
|
||||
$parentNode = $model->find(array($scope, $model->escapeField() => $model->data[$model->currentModel][$parent]),
|
||||
array($model->primaryKey), null, -1);
|
||||
|
||||
if (!$parentNode) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} elseif (isset($model->data[$model->name][$parent])) {
|
||||
if ($model->data[$model->name][$parent] != $model->field($parent)) {
|
||||
$this->settings[$model->name]['__parentChange'] = true;
|
||||
} elseif (isset($model->data[$model->currentModel][$parent])) {
|
||||
if ($model->data[$model->currentModel][$parent] != $model->field($parent)) {
|
||||
$this->settings[$model->currentModel]['__parentChange'] = true;
|
||||
}
|
||||
if (!$model->data[$model->name][$parent]) {
|
||||
$model->data[$model->name][$parent]= null;
|
||||
if (!$model->data[$model->currentModel][$parent]) {
|
||||
$model->data[$model->currentModel][$parent]= null;
|
||||
} else {
|
||||
list($node) = array_values($model->find(array($scope,$model->escapeField() => $model->id),
|
||||
array($model->primaryKey, $parent, $left, $right ), null, -1));
|
||||
|
||||
$parentNode = $model->find(array($scope, $model->escapeField() => $model->data[$model->name][$parent]),
|
||||
$parentNode = $model->find(array($scope, $model->escapeField() => $model->data[$model->currentModel][$parent]),
|
||||
array($model->primaryKey, $left, $right), null, -1);
|
||||
if (!$parentNode) {
|
||||
return false;
|
||||
|
@ -192,7 +192,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
} elseif (!$id) {
|
||||
$id = null;
|
||||
}
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
|
||||
if ($direct) {
|
||||
return $model->findCount(array($scope, $model->escapeField($parent) => $id));
|
||||
|
@ -201,7 +201,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
return $model->findCount($scope);
|
||||
}
|
||||
elseif (!empty ($model->data)) {
|
||||
$data = $model->data[$model->name];
|
||||
$data = $model->data[$model->currentModel];
|
||||
} else {
|
||||
list($data)= array_values($model->find(array($scope, $model->escapeField() => $id), null, null, -1));
|
||||
}
|
||||
|
@ -231,11 +231,11 @@ class TreeBehavior extends ModelBehavior {
|
|||
} elseif (!$id) {
|
||||
$id = null;
|
||||
}
|
||||
$name = $model->name;
|
||||
$name = $model->currentModel;
|
||||
extract($this->settings[$name]);
|
||||
|
||||
if (!$order) {
|
||||
$order = $model->name . '.' . $left . ' asc';
|
||||
$order = $model->currentModel . '.' . $left . ' asc';
|
||||
}
|
||||
if ($direct) {
|
||||
return $model->findAll(array($scope, $model->escapeField($parent) => $id), $fields, $order, $limit, $page, $recursive);
|
||||
|
@ -262,7 +262,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @access public
|
||||
*/
|
||||
function generatetreelist(&$model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = -1) {
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
|
||||
if ($keyPath == null && $valuePath == null && $model->hasField($model->displayField)) {
|
||||
$fields = array($model->primaryKey, $model->displayField, $left, $right);
|
||||
|
@ -271,11 +271,11 @@ class TreeBehavior extends ModelBehavior {
|
|||
}
|
||||
|
||||
if ($keyPath == null) {
|
||||
$keyPath = '{n}.' . $model->name . '.' . $model->primaryKey;
|
||||
$keyPath = '{n}.' . $model->currentModel . '.' . $model->primaryKey;
|
||||
}
|
||||
|
||||
if ($valuePath == null) {
|
||||
$valuePath = array('{0}{1}', '{n}.tree_prefix', '{n}.' . $model->name . '.' . $model->displayField);
|
||||
$valuePath = array('{0}{1}', '{n}.tree_prefix', '{n}.' . $model->currentModel . '.' . $model->displayField);
|
||||
|
||||
} elseif (is_string($valuePath)) {
|
||||
$valuePath = array('{0}{1}', '{n}.tree_prefix', $valuePath);
|
||||
|
@ -288,11 +288,11 @@ class TreeBehavior extends ModelBehavior {
|
|||
$stack = array();
|
||||
|
||||
foreach ($results as $i => $result) {
|
||||
while ($stack && ($stack[count($stack)-1] < $result[$model->name][$right])) {
|
||||
while ($stack && ($stack[count($stack)-1] < $result[$model->currentModel][$right])) {
|
||||
array_pop($stack);
|
||||
}
|
||||
$results[$i]['tree_prefix'] = str_repeat($spacer,count($stack));
|
||||
$stack[] = $result[$model->name][$right];
|
||||
$stack[] = $result[$model->currentModel][$right];
|
||||
}
|
||||
return Set::combine($results, $keyPath, $valuePath);
|
||||
}
|
||||
|
@ -311,11 +311,11 @@ class TreeBehavior extends ModelBehavior {
|
|||
if (empty ($id)) {
|
||||
$id = $model->id;
|
||||
}
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
$parentId = $model->read($parent, $id);
|
||||
|
||||
if ($parentId) {
|
||||
$parentId = $parentId[$model->name][$parent];
|
||||
$parentId = $parentId[$model->currentModel][$parent];
|
||||
$parent = $model->find(array($model->escapeField() => $parentId), $fields, null, $recursive);
|
||||
|
||||
return $parent;
|
||||
|
@ -337,7 +337,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
if (empty ($id)) {
|
||||
$id = $model->id;
|
||||
}
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
@list($item) = array_values($model->find(array($model->escapeField() => $id), array($left, $right), null, -1));
|
||||
|
||||
if (empty ($item)) {
|
||||
|
@ -366,7 +366,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
if (empty ($id)) {
|
||||
$id = $model->id;
|
||||
}
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
list($node) = array_values($model->find(array($scope, $model->escapeField() => $id),
|
||||
array($model->primaryKey, $left, $right, $parent), null, -1));
|
||||
if ($node[$parent]) {
|
||||
|
@ -410,7 +410,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
if (empty ($id)) {
|
||||
$id = $model->id;
|
||||
}
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
list($node) = array_values($model->find(array($scope, $model->escapeField() => $id),
|
||||
array($model->primaryKey, $left, $right, $parent ), null, -1));
|
||||
if ($node[$parent]) {
|
||||
|
@ -453,30 +453,30 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @access public
|
||||
*/
|
||||
function recover(&$model, $mode = 'parent') {
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
$model->recursive = -1;
|
||||
if ($mode == 'parent') {
|
||||
$count = 1;
|
||||
foreach ($model->findAll($scope, array($model->primaryKey), $left) as $array) {
|
||||
$model->{$model->primaryKey} = $array[$model->name][$model->primaryKey];
|
||||
$model->{$model->primaryKey} = $array[$model->currentModel][$model->primaryKey];
|
||||
$lft = $count++;
|
||||
$rght = $count++;
|
||||
$model->save(array($left => $lft,$right => $rght));
|
||||
}
|
||||
foreach ($model->findAll($scope, array($model->primaryKey,$parent), $left) as $array) {
|
||||
$model->create();
|
||||
$model->id = $array[$model->name][$model->primaryKey];
|
||||
$this->_setParent($model, $array[$model->name][$parent], true);
|
||||
$model->id = $array[$model->currentModel][$model->primaryKey];
|
||||
$this->_setParent($model, $array[$model->currentModel][$parent], true);
|
||||
}
|
||||
} else {
|
||||
foreach ($model->findAll($scope, array($model->primaryKey, $parent), $left) as $array) {
|
||||
$path = $this->getpath($model, $array[$model->name][$model->primaryKey]);
|
||||
$path = $this->getpath($model, $array[$model->currentModel][$model->primaryKey]);
|
||||
if ($path == null || count($path) < 2) {
|
||||
$parentId = null;
|
||||
} else {
|
||||
$parentId = $path[count($path) - 2][$model->name][$model->primaryKey];
|
||||
$parentId = $path[count($path) - 2][$model->currentModel][$model->primaryKey];
|
||||
}
|
||||
$model->updateAll(array($parent => $parentId), array($model->primaryKey => $array[$model->name][$model->primaryKey]));
|
||||
$model->updateAll(array($parent => $parentId), array($model->primaryKey => $array[$model->currentModel][$model->primaryKey]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
if (empty ($id)) {
|
||||
$id = $model->id;
|
||||
}
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
list($node) = array_values($model->find(
|
||||
array($scope, $model->escapeField() => $id),
|
||||
array($model->primaryKey, $left, $right, $parent), null, -1)
|
||||
|
@ -543,7 +543,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @access public
|
||||
*/
|
||||
function setparent(&$model, $parentId = null , $created = null) {
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
if ($created === false && $parentId == $model->field($parent)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @access public
|
||||
*/
|
||||
function verify(&$model) {
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
if (!$model->findCount($scope)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -586,24 +586,24 @@ class TreeBehavior extends ModelBehavior {
|
|||
|
||||
|
||||
$model->bindModel(array('belongsTo' => array('VerifyParent' => array(
|
||||
'className' => $model->name,
|
||||
'className' => $model->currentModel,
|
||||
'foreignKey' => $parent,
|
||||
'fields' => array($model->primaryKey, $left, $right, $parent)
|
||||
))));
|
||||
foreach ($model->findAll($scope, null, null, null, null, 1) as $instance) {
|
||||
if ($instance[$model->name][$parent]) {
|
||||
if ($instance[$model->currentModel][$parent]) {
|
||||
if (!$instance['VerifyParent'][$model->primaryKey]) {
|
||||
$errors[] = array('node', $instance[$model->name][$model->primaryKey],
|
||||
'The parent node ' . $instance[$model->name][$parent] . ' doesn\'t exist');
|
||||
} elseif ($instance[$model->name][$left] < $instance['VerifyParent'][$left]) {
|
||||
$errors[] = array('node', $instance[$model->name][$model->primaryKey],
|
||||
$errors[] = array('node', $instance[$model->currentModel][$model->primaryKey],
|
||||
'The parent node ' . $instance[$model->currentModel][$parent] . ' doesn\'t exist');
|
||||
} elseif ($instance[$model->currentModel][$left] < $instance['VerifyParent'][$left]) {
|
||||
$errors[] = array('node', $instance[$model->currentModel][$model->primaryKey],
|
||||
'left less than parent (node ' . $instance['VerifyParent'][$model->primaryKey] . ').');
|
||||
} elseif ($instance[$model->name][$right] > $instance['VerifyParent'][$right]) {
|
||||
$errors[] = array('node', $instance[$model->name][$model->primaryKey],
|
||||
} elseif ($instance[$model->currentModel][$right] > $instance['VerifyParent'][$right]) {
|
||||
$errors[] = array('node', $instance[$model->currentModel][$model->primaryKey],
|
||||
'right greater than parent (node ' . $instance['VerifyParent'][$model->primaryKey] . ').');
|
||||
}
|
||||
} elseif ($model->findCount(array($scope, $left . '< ' . $instance[$model->name][$left], $right . '> ' . $instance[$model->name][$right]))) {
|
||||
$errors[] = array('node', $instance[$model->name][$model->primaryKey], 'The parent field is blank, but has a parent');
|
||||
} elseif ($model->findCount(array($scope, $left . '< ' . $instance[$model->currentModel][$left], $right . '> ' . $instance[$model->currentModel][$right]))) {
|
||||
$errors[] = array('node', $instance[$model->currentModel][$model->primaryKey], 'The parent field is blank, but has a parent');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -626,7 +626,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @access protected
|
||||
*/
|
||||
function _setParent(&$model, $parentId = null) {
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
list($node) = array_values($model->find(array($scope, $model->escapeField() => $model->id),
|
||||
array($model->primaryKey, $parent, $left, $right), null, -1));
|
||||
$edge = $this->__getMax($model, $scope, $right);
|
||||
|
@ -710,7 +710,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @access private
|
||||
*/
|
||||
function __sync(&$model, $shift, $dir = '+', $conditions = array(), $field = 'both') {
|
||||
extract($this->settings[$model->name]);
|
||||
extract($this->settings[$model->currentModel]);
|
||||
if ($field == 'both') {
|
||||
$this->__sync($model, $shift, $dir, $conditions, $left);
|
||||
$field = $right;
|
||||
|
|
|
@ -408,9 +408,9 @@ class DataSource extends Object {
|
|||
if (strpos($query, $key) !== false) {
|
||||
switch($key) {
|
||||
case '{$__cakeID__$}':
|
||||
if (isset($data[$model->name]) || isset($data[$association])) {
|
||||
if (isset($data[$model->name][$model->primaryKey])) {
|
||||
$val = $data[$model->name][$model->primaryKey];
|
||||
if (isset($data[$model->currentModel]) || isset($data[$association])) {
|
||||
if (isset($data[$model->currentModel][$model->primaryKey])) {
|
||||
$val = $data[$model->currentModel][$model->primaryKey];
|
||||
} elseif (isset($data[$association][$model->primaryKey])) {
|
||||
$val = $data[$association][$model->primaryKey];
|
||||
}
|
||||
|
@ -435,8 +435,8 @@ class DataSource extends Object {
|
|||
if (isset($assoc['foreignKey'])) {
|
||||
$foreignKey = $assoc['foreignKey'];
|
||||
|
||||
if (isset($data[$model->name][$foreignKey])) {
|
||||
$val = $data[$model->name][$foreignKey];
|
||||
if (isset($data[$model->currentModel][$foreignKey])) {
|
||||
$val = $data[$model->currentModel][$foreignKey];
|
||||
} elseif (isset($data[$association][$foreignKey])) {
|
||||
$val = $data[$association][$foreignKey];
|
||||
} else {
|
||||
|
@ -475,7 +475,7 @@ class DataSource extends Object {
|
|||
* @return unknown
|
||||
*/
|
||||
function resolveKey($model, $key) {
|
||||
return $model->name . $key;
|
||||
return $model->currentModel . $key;
|
||||
}
|
||||
/**
|
||||
* Closes the current datasource.
|
||||
|
|
|
@ -334,7 +334,7 @@ class DboAdodb extends DboSource {
|
|||
*/
|
||||
function fields(&$model, $alias = null, $fields = null, $quote = true) {
|
||||
if (empty($alias)) {
|
||||
$alias = $model->name;
|
||||
$alias = $model->currentModel;
|
||||
}
|
||||
|
||||
if (!is_array($fields)) {
|
||||
|
|
|
@ -189,7 +189,7 @@ class DboFirebird extends DboSource {
|
|||
* @return array Fields in table. Keys are name and type
|
||||
*/
|
||||
function describe(&$model) {
|
||||
$this->modeltmp[$model->table] = $model->name;
|
||||
$this->modeltmp[$model->table] = $model->currentModel;
|
||||
$cache = parent::describe($model);
|
||||
|
||||
if ($cache != null) {
|
||||
|
|
|
@ -265,7 +265,7 @@ class DboMssql extends DboSource {
|
|||
*/
|
||||
function fields(&$model, $alias = null, $fields = array(), $quote = true) {
|
||||
if (empty($alias)) {
|
||||
$alias = $model->name;
|
||||
$alias = $model->currentModel;
|
||||
}
|
||||
$fields = parent::fields($model, $alias, $fields, false);
|
||||
$count = count($fields);
|
||||
|
|
|
@ -374,7 +374,7 @@ class DboPostgres extends DboSource {
|
|||
*/
|
||||
function fields(&$model, $alias = null, $fields = array(), $quote = true) {
|
||||
if (empty($alias)) {
|
||||
$alias = $model->name;
|
||||
$alias = $model->currentModel;
|
||||
}
|
||||
$fields = parent::fields($model, $alias, $fields, false);
|
||||
|
||||
|
|
|
@ -220,9 +220,9 @@ class DboSource extends DataSource {
|
|||
$query = array();
|
||||
foreach ($field as $f) {
|
||||
if (!is_array($params[$c]) && !empty($params[$c]) && $params[$c] !== true && $params[$c] !== false) {
|
||||
$query[$args[2]->name . '.' . $f] = '= ' . $params[$c];
|
||||
$query[$args[2]->currentModel . '.' . $f] = '= ' . $params[$c];
|
||||
} else {
|
||||
$query[$args[2]->name . '.' . $f] = $params[$c];
|
||||
$query[$args[2]->currentModel . '.' . $f] = $params[$c];
|
||||
}
|
||||
$c++;
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ class DboSource extends DataSource {
|
|||
$linkModel =& $model->{$assoc};
|
||||
|
||||
$external = isset($assocData['external']);
|
||||
if ($model->name == $linkModel->name && $type != 'hasAndBelongsToMany' && $type != 'hasMany') {
|
||||
if ($model->currentModel == $linkModel->currentModel && $type != 'hasAndBelongsToMany' && $type != 'hasMany') {
|
||||
if (true === $this->generateSelfAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) {
|
||||
$linkedModels[] = $type . '/' . $assoc;
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
// Build final query SQL
|
||||
$query = $this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null);
|
||||
$resultSet = $this->fetchAll($query, $model->cacheQueries, $model->name);
|
||||
$resultSet = $this->fetchAll($query, $model->cacheQueries, $model->currentModel);
|
||||
|
||||
if ($resultSet === false) {
|
||||
$model->onError();
|
||||
|
@ -633,7 +633,7 @@ class DboSource extends DataSource {
|
|||
for ($j = 0; $j < $count2; $j++) {
|
||||
$className = $key = $keys[$j];
|
||||
|
||||
if ($model->name != $className && !in_array($key, $filtered)) {
|
||||
if ($model->currentModel != $className && !in_array($key, $filtered)) {
|
||||
if (!in_array($key, $filtering)) {
|
||||
$filtering[] = $key;
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ class DboSource extends DataSource {
|
|||
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
|
||||
if (!isset($resultSet) || !is_array($resultSet)) {
|
||||
if (Configure::read() > 0) {
|
||||
e('<div style = "font: Verdana bold 12px; color: #FF0000">' . sprintf(__('SQL Error in model %s:', true), $model->name) . ' ');
|
||||
e('<div style = "font: Verdana bold 12px; color: #FF0000">' . sprintf(__('SQL Error in model %s:', true), $model->currentModel) . ' ');
|
||||
if (isset($this->error) && $this->error != null) {
|
||||
e($this->error);
|
||||
}
|
||||
|
@ -689,7 +689,7 @@ class DboSource extends DataSource {
|
|||
|
||||
if (!empty($ins)) {
|
||||
$query = r('{$__cakeID__$}', join(', ', $ins), $query);
|
||||
$fetch = $this->fetchAll($query, $model->cacheQueries, $model->name);
|
||||
$fetch = $this->fetchAll($query, $model->cacheQueries, $model->currentModel);
|
||||
}
|
||||
|
||||
if (!empty($fetch) && is_array($fetch)) {
|
||||
|
@ -699,7 +699,7 @@ class DboSource extends DataSource {
|
|||
foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
|
||||
|
||||
$deepModel =& $linkModel->{$assoc1};
|
||||
if ($deepModel->alias != $model->name) {
|
||||
if ($deepModel->alias != $model->currentModel) {
|
||||
$tmpStack = $stack;
|
||||
$tmpStack[] = $assoc1;
|
||||
if ($linkModel->useDbConfig == $deepModel->useDbConfig) {
|
||||
|
@ -735,7 +735,7 @@ class DboSource extends DataSource {
|
|||
|
||||
$q = $this->insertQueryData($query, null, $association, $assocData, $model, $linkModel, $stack);
|
||||
if ($q != false) {
|
||||
$fetch = $this->fetchAll($q, $model->cacheQueries, $model->name);
|
||||
$fetch = $this->fetchAll($q, $model->cacheQueries, $model->currentModel);
|
||||
} else {
|
||||
$fetch = null;
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ class DboSource extends DataSource {
|
|||
if ($type !== 'hasAndBelongsToMany') {
|
||||
$q = $this->insertQueryData($query, $resultSet[$i], $association, $assocData, $model, $linkModel, $stack);
|
||||
if ($q != false) {
|
||||
$fetch = $this->fetchAll($q, $model->cacheQueries, $model->name);
|
||||
$fetch = $this->fetchAll($q, $model->cacheQueries, $model->currentModel);
|
||||
} else {
|
||||
$fetch = null;
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ class DboSource extends DataSource {
|
|||
foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
|
||||
|
||||
$deepModel =& $linkModel->{$assoc1};
|
||||
if (($type1 === 'belongsTo') || ($deepModel->name === $model->name && $type === 'belongsTo') || ($deepModel->name != $model->name)) {
|
||||
if (($type1 === 'belongsTo') || ($deepModel->currentModel === $model->currentModel && $type === 'belongsTo') || ($deepModel->currentModel != $model->currentModel)) {
|
||||
$tmpStack = $stack;
|
||||
$tmpStack[] = $assoc1;
|
||||
if ($linkModel->useDbConfig == $deepModel->useDbConfig) {
|
||||
|
@ -776,7 +776,7 @@ class DboSource extends DataSource {
|
|||
if ($type == 'hasAndBelongsToMany') {
|
||||
$merge = array();
|
||||
foreach($fetch as $j => $data) {
|
||||
if(isset($data[$with]) && $data[$with][$foreignKey] === $row[$model->name][$model->primaryKey]) {
|
||||
if(isset($data[$with]) && $data[$with][$foreignKey] === $row[$model->currentModel][$model->primaryKey]) {
|
||||
if ($habtmFieldsCount > 2) {
|
||||
$merge[] = $data;
|
||||
} else {
|
||||
|
@ -807,10 +807,16 @@ class DboSource extends DataSource {
|
|||
$count = 0;
|
||||
$merged[$association] = array();
|
||||
foreach ($merge as $j => $data) {
|
||||
if (isset($value[$model->name]) && $value[$model->name][$model->primaryKey] === $data[$association][$model->hasMany[$association]['foreignKey']]) {
|
||||
if (isset($value[$model->currentModel]) && $value[$model->currentModel][$model->primaryKey] === $data[$association][$model->hasMany[$association]['foreignKey']]) {
|
||||
if (count($data) > 1) {
|
||||
$data = am($data[$association], $data);
|
||||
unset($data[$association]);
|
||||
foreach ($data as $key => $name) {
|
||||
if (is_numeric($key)) {
|
||||
$data[$association][] = $name;
|
||||
unset($data[$key]);
|
||||
}
|
||||
}
|
||||
$merged[$association][] = $data;
|
||||
} else {
|
||||
$merged[$association][] = $data[$association];
|
||||
|
@ -818,9 +824,9 @@ class DboSource extends DataSource {
|
|||
}
|
||||
$count++;
|
||||
}
|
||||
if (isset($value[$model->name])) {
|
||||
if (isset($value[$model->currentModel])) {
|
||||
$resultSet[$i] = Set::pushDiff($resultSet[$i], $merged);
|
||||
unset($temp);
|
||||
unset($merged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -912,7 +918,7 @@ class DboSource extends DataSource {
|
|||
function generateSelfAssociationQuery(&$model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
|
||||
$alias = $association;
|
||||
if (empty($alias) && !empty($linkModel)) {
|
||||
$alias = $linkModel->name;
|
||||
$alias = $linkModel->currentModel;
|
||||
}
|
||||
|
||||
if (!isset($queryData['selfJoin'])) {
|
||||
|
@ -928,7 +934,7 @@ class DboSource extends DataSource {
|
|||
$model->escapeField($assocData['foreignKey']) => '{$__cakeIdentifier[' . "{$alias}.{$linkModel->primaryKey}" . ']__$}'))
|
||||
),
|
||||
'table' => $this->fullTableName($model),
|
||||
'alias' => $model->name,
|
||||
'alias' => $model->currentModel,
|
||||
'limit' => $queryData['limit'],
|
||||
'offset' => $queryData['offset'],
|
||||
'conditions'=> $queryData['conditions'],
|
||||
|
@ -995,10 +1001,10 @@ class DboSource extends DataSource {
|
|||
$joinedOnSelf = false;
|
||||
|
||||
if (empty($queryData['fields'])) {
|
||||
$queryData['fields'] = $this->fields($model, $model->name);
|
||||
$queryData['fields'] = $this->fields($model, $model->currentModel);
|
||||
} elseif (!empty($model->hasMany) && $model->recursive > -1) {
|
||||
$assocFields = $this->fields($model, $model->name, array("{$model->name}.{$model->primaryKey}"));
|
||||
$passedFields = $this->fields($model, $model->name, $queryData['fields']);
|
||||
$assocFields = $this->fields($model, $model->currentModel, array("{$model->currentModel}.{$model->primaryKey}"));
|
||||
$passedFields = $this->fields($model, $model->currentModel, $queryData['fields']);
|
||||
|
||||
if (count($passedFields) === 1) {
|
||||
$match = strpos($passedFields[0], $assocFields[0]);
|
||||
|
@ -1021,7 +1027,7 @@ class DboSource extends DataSource {
|
|||
return $this->buildStatement(array(
|
||||
'fields' => array_unique($queryData['fields']),
|
||||
'table' => $this->fullTableName($model),
|
||||
'alias' => $model->name,
|
||||
'alias' => $model->currentModel,
|
||||
'limit' => $queryData['limit'],
|
||||
'offset' => $queryData['offset'],
|
||||
'joins' => $queryData['joins'],
|
||||
|
@ -1032,7 +1038,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
$alias = $association;
|
||||
|
||||
if ($model->name == $linkModel->name) {
|
||||
if ($model->currentModel == $linkModel->currentModel) {
|
||||
$joinedOnSelf = true;
|
||||
}
|
||||
|
||||
|
@ -1081,9 +1087,9 @@ class DboSource extends DataSource {
|
|||
}
|
||||
} else {
|
||||
if ($type == 'hasOne') {
|
||||
$conditions = $this->__mergeConditions($assocData['conditions'], array("{$alias}.{$assocData['foreignKey']}" => '{$__cakeIdentifier[' . "{$model->name}.{$model->primaryKey}" . ']__$}'));
|
||||
$conditions = $this->__mergeConditions($assocData['conditions'], array("{$alias}.{$assocData['foreignKey']}" => '{$__cakeIdentifier[' . "{$model->currentModel}.{$model->primaryKey}" . ']__$}'));
|
||||
} elseif ($type == 'belongsTo') {
|
||||
$conditions = $this->__mergeConditions($assocData['conditions'], array("{$model->name}.{$assocData['foreignKey']}" => '{$__cakeIdentifier[' . "{$alias}.{$linkModel->primaryKey}" . ']__$}'));
|
||||
$conditions = $this->__mergeConditions($assocData['conditions'], array("{$model->currentModel}.{$assocData['foreignKey']}" => '{$__cakeIdentifier[' . "{$alias}.{$linkModel->primaryKey}" . ']__$}'));
|
||||
}
|
||||
|
||||
$join = array(
|
||||
|
@ -1130,8 +1136,8 @@ class DboSource extends DataSource {
|
|||
$joinFields = $joinFields->extract('{n}.name');
|
||||
|
||||
if (is_array($joinFields) && !empty($joinFields)) {
|
||||
$joinFields = $this->fields($model->{$assocData['with']}, $model->{$assocData['with']}->name, $joinFields);
|
||||
$joinAssoc = $joinAlias = $model->{$assocData['with']}->name;
|
||||
$joinFields = $this->fields($model->{$assocData['with']}, $model->{$assocData['with']}->currentModel, $joinFields);
|
||||
$joinAssoc = $joinAlias = $model->{$assocData['with']}->currentModel;
|
||||
|
||||
} else {
|
||||
$joinFields = array();
|
||||
|
@ -1328,10 +1334,10 @@ class DboSource extends DataSource {
|
|||
*/
|
||||
function resolveKey($model, $key, $assoc = null) {
|
||||
if (empty($assoc)) {
|
||||
$assoc = $model->name;
|
||||
$assoc = $model->currentModel;
|
||||
}
|
||||
if (!strpos('.', $key)) {
|
||||
return $this->name($model->name) . '.' . $this->name($key);
|
||||
return $this->name($model->currentModel) . '.' . $this->name($key);
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
@ -1367,7 +1373,7 @@ class DboSource extends DataSource {
|
|||
*/
|
||||
function fields(&$model, $alias = null, $fields = array(), $quote = true) {
|
||||
if (empty($alias)) {
|
||||
$alias = $model->name;
|
||||
$alias = $model->currentModel;
|
||||
}
|
||||
|
||||
if (!is_array($fields)) {
|
||||
|
|
|
@ -74,7 +74,7 @@ class AclNode extends AppModel {
|
|||
*/
|
||||
function node($ref = null) {
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
$type = $this->name;
|
||||
$type = $this->currentModel;
|
||||
$prefix = $this->tablePrefix;
|
||||
$result = null;
|
||||
|
||||
|
@ -119,13 +119,13 @@ class AclNode extends AppModel {
|
|||
$result = $db->read($this, $queryData, -1);
|
||||
|
||||
} elseif (is_object($ref) && is_a($ref, 'Model')) {
|
||||
$ref = array('model' => $ref->name, 'foreign_key' => $ref->id);
|
||||
$ref = array('model' => $ref->currentModel, 'foreign_key' => $ref->id);
|
||||
|
||||
} elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {
|
||||
$name = key($ref);
|
||||
if (!ClassRegistry::isKeySet($name)) {
|
||||
if (!loadModel($name)) {
|
||||
trigger_error("Model class '$name' not found in AclNode::node() when trying to bind {$this->name} object", E_USER_WARNING);
|
||||
trigger_error("Model class '$name' not found in AclNode::node() when trying to bind {$this->currentModel} object", E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
$model =& new $name();
|
||||
|
|
|
@ -355,10 +355,10 @@ class Model extends Overloadable {
|
|||
}
|
||||
|
||||
if (isset($options['alias']) || !empty($options['alias'])) {
|
||||
$this->currentModel = Inflector::underscore($options['alias']);
|
||||
$this->currentModel = $options['alias'];
|
||||
unset($options);
|
||||
} else {
|
||||
$this->currentModel = Inflector::underscore($this->name);
|
||||
$this->currentModel = $this->name;
|
||||
}
|
||||
|
||||
ClassRegistry::addObject($this->currentModel, $this);
|
||||
|
@ -697,7 +697,7 @@ class Model extends Overloadable {
|
|||
}
|
||||
|
||||
$this->alias[$assoc] = $this->{$assoc}->table;
|
||||
$this->tableToModel[$this->{$assoc}->table] = $className;
|
||||
$this->tableToModel[$this->{$assoc}->table] = $assoc;
|
||||
$this->modelToTable[$assoc] = $this->{$assoc}->table;
|
||||
}
|
||||
/**
|
||||
|
@ -795,7 +795,7 @@ class Model extends Overloadable {
|
|||
$sources = $db->listSources();
|
||||
if (is_array($sources) && !in_array(low($this->tablePrefix . $tableName), array_map('low', $sources))) {
|
||||
return $this->cakeError('missingTable', array(array(
|
||||
'className' => $this->name,
|
||||
'className' => $this->currentModel,
|
||||
'table' => $this->tablePrefix . $tableName)));
|
||||
|
||||
}
|
||||
|
@ -825,24 +825,24 @@ class Model extends Overloadable {
|
|||
|
||||
if (is_array($one)) {
|
||||
if (Set::countDim($one) == 1) {
|
||||
$data = array($this->name => $one);
|
||||
$data = array($this->currentModel => $one);
|
||||
} else {
|
||||
$data = $one;
|
||||
}
|
||||
} else {
|
||||
$data = array($this->name => array($one => $two));
|
||||
$data = array($this->currentModel => array($one => $two));
|
||||
}
|
||||
|
||||
foreach ($data as $n => $v) {
|
||||
if (is_array($v)) {
|
||||
|
||||
foreach ($v as $x => $y) {
|
||||
if (empty($this->whitelist) || (in_array($x, $this->whitelist) || $n !== $this->name)) {
|
||||
if (empty($this->whitelist) || (in_array($x, $this->whitelist) || $n !== $this->currentModel)) {
|
||||
if (isset($this->validationErrors[$x])) {
|
||||
unset ($this->validationErrors[$x]);
|
||||
}
|
||||
|
||||
if ($n === $this->name) {
|
||||
if ($n === $this->currentModel) {
|
||||
if ($x === $this->primaryKey) {
|
||||
$this->id = $y;
|
||||
}
|
||||
|
@ -991,7 +991,7 @@ class Model extends Overloadable {
|
|||
}
|
||||
|
||||
if ($this->id !== null && $this->id !== false) {
|
||||
$this->data = $this->find(array($this->name . '.' . $this->primaryKey => $id), $fields);
|
||||
$this->data = $this->find(array($this->currentModel . '.' . $this->primaryKey => $id), $fields);
|
||||
return $this->data;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1007,7 +1007,7 @@ class Model extends Overloadable {
|
|||
*/
|
||||
function field($name, $conditions = null, $order = null) {
|
||||
if ($conditions === null && $this->id !== false) {
|
||||
$conditions = array($this->name . '.' . $this->primaryKey => $this->id);
|
||||
$conditions = array($this->currentModel . '.' . $this->primaryKey => $this->id);
|
||||
}
|
||||
if ($this->recursive >= 1) {
|
||||
$recursive = -1;
|
||||
|
@ -1017,8 +1017,8 @@ class Model extends Overloadable {
|
|||
if ($data = $this->find($conditions, $name, $order, $recursive)) {
|
||||
|
||||
if (strpos($name, '.') === false) {
|
||||
if (isset($data[$this->name][$name])) {
|
||||
return $data[$this->name][$name];
|
||||
if (isset($data[$this->currentModel][$name])) {
|
||||
return $data[$this->currentModel][$name];
|
||||
}
|
||||
} else {
|
||||
$name = explode('.', $name);
|
||||
|
@ -1043,7 +1043,7 @@ class Model extends Overloadable {
|
|||
* @return boolean True on success save
|
||||
*/
|
||||
function saveField($name, $value, $validate = false) {
|
||||
return $this->save(array($this->name => array($name => $value)), $validate, array($name));
|
||||
return $this->save(array($this->currentModel => array($name => $value)), $validate, array($name));
|
||||
}
|
||||
/**
|
||||
* Saves model data to the database.
|
||||
|
@ -1071,13 +1071,13 @@ class Model extends Overloadable {
|
|||
}
|
||||
|
||||
foreach (array('created', 'updated', 'modified') as $field) {
|
||||
if (array_key_exists($field, $this->data[$this->name]) && $this->data[$this->name][$field] === null) {
|
||||
unset($this->data[$this->name][$field]);
|
||||
if (array_key_exists($field, $this->data[$this->currentModel]) && $this->data[$this->currentModel][$field] === null) {
|
||||
unset($this->data[$this->currentModel][$field]);
|
||||
}
|
||||
}
|
||||
|
||||
$exists = $this->exists();
|
||||
$fields = array_keys($this->data[$this->name]);
|
||||
$fields = array_keys($this->data[$this->currentModel]);
|
||||
|
||||
if (!$exists && $this->hasField('created') && !in_array('created', $fields)) {
|
||||
$colType = am(array('formatter' => 'date'), $db->columns[$this->getColumnType('created')]);
|
||||
|
@ -1118,7 +1118,7 @@ class Model extends Overloadable {
|
|||
if (isset($v[$n]) && $habtm > 0) {
|
||||
$joined[] = $v;
|
||||
} else {
|
||||
if ($n === $this->name) {
|
||||
if ($n === $this->currentModel) {
|
||||
foreach (array('created', 'updated', 'modified') as $field) {
|
||||
if (array_key_exists($field, $v) && empty($v[$field])) {
|
||||
unset($v[$field]);
|
||||
|
@ -1150,7 +1150,7 @@ class Model extends Overloadable {
|
|||
} else {
|
||||
foreach ($this->_tableInfo->value as $key => $value) {
|
||||
if (in_array($this->primaryKey, $value)) {
|
||||
if (empty($this->data[$this->name][$this->primaryKey]) && $this->_tableInfo->value[$key]['type'] === 'string' && $this->_tableInfo->value[$key]['length'] === 36) {
|
||||
if (empty($this->data[$this->currentModel][$this->primaryKey]) && $this->_tableInfo->value[$key]['type'] === 'string' && $this->_tableInfo->value[$key]['length'] === 36) {
|
||||
$fields[] = $this->primaryKey;
|
||||
$values[] = String::uuid();
|
||||
}
|
||||
|
@ -1343,7 +1343,7 @@ class Model extends Overloadable {
|
|||
|
||||
if (!empty($records)) {
|
||||
foreach ($records as $record) {
|
||||
$model->delete($record[$model->name][$model->primaryKey]);
|
||||
$model->delete($record[$model->currentModel][$model->primaryKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1368,7 +1368,7 @@ class Model extends Overloadable {
|
|||
|
||||
if (!empty($records)) {
|
||||
foreach ($records as $record) {
|
||||
$model->delete($record[$model->name][$model->primaryKey]);
|
||||
$model->delete($record[$model->currentModel][$model->primaryKey]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1393,7 +1393,7 @@ class Model extends Overloadable {
|
|||
if (empty($records)) {
|
||||
return false;
|
||||
}
|
||||
$ids = Set::extract($records, "{n}.{$this->name}.{$this->primaryKey}");
|
||||
$ids = Set::extract($records, "{n}.{$this->currentModel}.{$this->primaryKey}");
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$this->_deleteLinks($id);
|
||||
|
@ -1416,7 +1416,7 @@ class Model extends Overloadable {
|
|||
if ($this->__exists !== null && $reset !== true) {
|
||||
return $this->__exists;
|
||||
}
|
||||
return $this->__exists = ($this->findCount(array($this->name . '.' . $this->primaryKey => $this->getID()), -1) > 0);
|
||||
return $this->__exists = ($this->findCount(array($this->currentModel . '.' . $this->primaryKey => $this->getID()), -1) > 0);
|
||||
}
|
||||
/**
|
||||
* Returns true if a record that meets given conditions exists
|
||||
|
@ -1519,8 +1519,8 @@ class Model extends Overloadable {
|
|||
case 'count':
|
||||
if (isset($results[0][0]['count'])) {
|
||||
return intval($results[0][0]['count']);
|
||||
} elseif (isset($results[0][$this->name]['count'])) {
|
||||
return intval($results[0][$this->name]['count']);
|
||||
} elseif (isset($results[0][$this->currentModel]['count'])) {
|
||||
return intval($results[0][$this->currentModel]['count']);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
@ -1646,8 +1646,8 @@ class Model extends Overloadable {
|
|||
unset($fields[$field]);
|
||||
|
||||
$field = $value;
|
||||
if (isset($this->data[$this->name][$field])) {
|
||||
$value = $this->data[$this->name][$field];
|
||||
if (isset($this->data[$this->currentModel][$field])) {
|
||||
$value = $this->data[$this->currentModel][$field];
|
||||
} else {
|
||||
$value = null;
|
||||
}
|
||||
|
@ -1655,7 +1655,7 @@ class Model extends Overloadable {
|
|||
|
||||
if (strpos($field, '.') === false) {
|
||||
unset($fields[$field]);
|
||||
$fields[$this->name . '.' . $field] = $value;
|
||||
$fields[$this->currentModel . '.' . $field] = $value;
|
||||
}
|
||||
}
|
||||
if ($or) {
|
||||
|
@ -1690,11 +1690,11 @@ class Model extends Overloadable {
|
|||
$sizeOf = sizeof($data);
|
||||
|
||||
for ($ii = 0; $ii < $sizeOf; $ii++) {
|
||||
if (($data[$ii][$this->name]['parent_id'] == $root) || (($root === null) && ($data[$ii][$this->name]['parent_id'] == '0'))) {
|
||||
if (($data[$ii][$this->currentModel]['parent_id'] == $root) || (($root === null) && ($data[$ii][$this->currentModel]['parent_id'] == '0'))) {
|
||||
$tmp = $data[$ii];
|
||||
|
||||
if (isset($data[$ii][$this->name][$this->primaryKey])) {
|
||||
$tmp['children'] = $this->__doThread($data, $data[$ii][$this->name][$this->primaryKey]);
|
||||
if (isset($data[$ii][$this->currentModel][$this->primaryKey])) {
|
||||
$tmp['children'] = $this->__doThread($data, $data[$ii][$this->currentModel][$this->primaryKey]);
|
||||
} else {
|
||||
$tmp['children'] = null;
|
||||
}
|
||||
|
@ -1790,8 +1790,8 @@ class Model extends Overloadable {
|
|||
return $this->validationErrors;
|
||||
}
|
||||
|
||||
if (isset($data[$this->name])) {
|
||||
$data = $data[$this->name];
|
||||
if (isset($data[$this->currentModel])) {
|
||||
$data = $data[$this->currentModel];
|
||||
}
|
||||
|
||||
$Validation = new Validation();
|
||||
|
@ -1939,11 +1939,11 @@ class Model extends Overloadable {
|
|||
}
|
||||
|
||||
if ($keyPath == null) {
|
||||
$keyPath = '{n}.' . $this->name . '.' . $this->primaryKey;
|
||||
$keyPath = '{n}.' . $this->currentModel . '.' . $this->primaryKey;
|
||||
}
|
||||
|
||||
if ($valuePath == null) {
|
||||
$valuePath = '{n}.' . $this->name . '.' . $this->displayField;
|
||||
$valuePath = '{n}.' . $this->currentModel . '.' . $this->displayField;
|
||||
}
|
||||
|
||||
return Set::combine($result, $keyPath, $valuePath, $groupPath);
|
||||
|
@ -1956,7 +1956,7 @@ class Model extends Overloadable {
|
|||
*/
|
||||
function escapeField($field = null, $alias = null) {
|
||||
if (empty($alias)) {
|
||||
$alias = $this->name;
|
||||
$alias = $this->currentModel;
|
||||
}
|
||||
if (empty($field)) {
|
||||
$field = $this->primaryKey;
|
||||
|
@ -2054,7 +2054,7 @@ class Model extends Overloadable {
|
|||
}
|
||||
|
||||
if (empty($db) || $db == null || !is_object($db)) {
|
||||
return $this->cakeError('missingConnection', array(array('className' => $this->name)));
|
||||
return $this->cakeError('missingConnection', array(array('className' => $this->currentModel)));
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -2176,7 +2176,7 @@ class Model extends Overloadable {
|
|||
function _clearCache($type = null) {
|
||||
if ($type === null) {
|
||||
if (Configure::read('Cache.check') === true) {
|
||||
$assoc[] = strtolower(Inflector::pluralize($this->name));
|
||||
$assoc[] = strtolower(Inflector::pluralize($this->currentModel));
|
||||
foreach ($this->__associations as $key => $association) {
|
||||
foreach ($this->$association as $key => $className) {
|
||||
$check = strtolower(Inflector::pluralize($className['className']));
|
||||
|
|
|
@ -787,13 +787,13 @@ class View extends Object {
|
|||
$cache->view = &$this;
|
||||
}
|
||||
|
||||
$cache->base = $this->base;
|
||||
$cache->here = $this->here;
|
||||
$cache->helpers = $this->helpers;
|
||||
$cache->action = $this->action;
|
||||
$cache->controllerName = $this->name;
|
||||
$cache->base = $this->base;
|
||||
$cache->here = $this->here;
|
||||
$cache->helpers = $this->helpers;
|
||||
$cache->action = $this->action;
|
||||
$cache->controllerName = $this->name;
|
||||
$cache->layout = $this->layout;
|
||||
$cache->cacheAction = $this->cacheAction;
|
||||
$cache->cacheAction = $this->cacheAction;
|
||||
$cache->cache($___viewFn, $out, $cached);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -631,7 +631,7 @@ class DboSourceTest extends UnitTestCase {
|
|||
$linkModel =& $this->model->Category2->{$assoc};
|
||||
$external = isset($assocData['external']);
|
||||
|
||||
if ($this->model->Category2->name == $linkModel->name && $type != 'hasAndBelongsToMany' && $type != 'hasMany') {
|
||||
if ($this->model->Category2->currentModel == $linkModel->currentModel && $type != 'hasAndBelongsToMany' && $type != 'hasMany') {
|
||||
$result = $this->db->generateSelfAssociationQuery($this->model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null);
|
||||
$this->assertTrue($result);
|
||||
} else {
|
||||
|
|
|
@ -570,7 +570,7 @@ class ModelTest extends CakeTestCase {
|
|||
|
||||
function testIdentity() {
|
||||
$this->model =& new Test();
|
||||
$result = $this->model->name;
|
||||
$result = $this->model->currentModel;
|
||||
$expected = 'Test';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
@ -2536,35 +2536,56 @@ class ModelTest extends CakeTestCase {
|
|||
|
||||
$result = $this->model->findAll();
|
||||
$expected = array(array('Apple' => array (
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04','modified' => '2006-12-01 13:31:26'),
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array('id' => 2,'apple_id' => 2,'name' => 'sample2')),
|
||||
'Sample' => array('id' => '','apple_id' => '','name' => ''),
|
||||
'Child' => array(array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01','modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2')))),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' =>'', 'apple_id' => '', 'name' => ''),
|
||||
'Child' => array(
|
||||
array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))))),
|
||||
array('Apple' => array(
|
||||
'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Parent' => array ('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01','modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array()),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2',
|
||||
'Apple' => array ('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10')),
|
||||
'Child' => array(array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array()),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array('id' => 1, 'apple_id' => 3, 'name' => 'sample1')),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3')))),
|
||||
'Apple' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10')),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array('id' => 1, 'apple_id' => 3, 'name' => 'sample1')),
|
||||
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3'),
|
||||
'Child' => array(
|
||||
array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'))))),
|
||||
array('Apple' => array(
|
||||
'id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array( 'id' => 2, 'apple_id' => 2, 'name' => 'sample2')),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 1, 'apple_id' => 3, 'name' => 'sample1',
|
||||
'Apple' => array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24')),
|
||||
'Child' => array()),
|
||||
|
@ -2572,114 +2593,163 @@ class ModelTest extends CakeTestCase {
|
|||
'id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2')),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3',
|
||||
'Apple' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36')),
|
||||
'Child' => array(array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39',
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Sample' => array()))),
|
||||
'Child' => array(
|
||||
array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39',
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'))))),
|
||||
array('Apple' => array(
|
||||
'id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16',
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4')),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4'),
|
||||
'Child' => array(
|
||||
array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'))),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4',
|
||||
'Apple' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16')),
|
||||
'Child' => array(array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16',
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4')))),
|
||||
'Child' => array(
|
||||
array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16',
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4'),
|
||||
'Child' => array(
|
||||
array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'))))),
|
||||
array('Apple' => array(
|
||||
'id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'),
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array( 'id' => 3, 'apple_id' => 6, 'name' => 'sample3')),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3'),
|
||||
'Child' => array(
|
||||
array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => ''),
|
||||
'Child' => array(array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21',
|
||||
'Parent' => array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'),
|
||||
'Sample' => array()))),
|
||||
'Child' => array(
|
||||
array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21',
|
||||
'Parent' => array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'),
|
||||
'Sample' => array()))),
|
||||
array('Apple' => array(
|
||||
'id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'),
|
||||
'Parent' => array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39',
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Sample' => array()),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => ''),
|
||||
'Child' => array()));
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => ''),
|
||||
'Child' => array()));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->model =& new Apple();
|
||||
$this->model->recursive = 2;
|
||||
|
||||
$result = $this->model->Parent->unbindModel(array('hasOne' => array('Sample')));
|
||||
$this->assertTrue($result);
|
||||
|
||||
$result = $this->model->findAll();
|
||||
$expected = array(array('Apple' => array (
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04','modified' => '2006-12-01 13:31:26'),
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26')),
|
||||
'Sample' => array('id' => '','apple_id' => '','name' => ''),
|
||||
'Child' => array(array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01','modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2')))),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' =>'', 'apple_id' => '', 'name' => ''),
|
||||
'Child' => array(
|
||||
array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))))),
|
||||
array('Apple' => array(
|
||||
'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Parent' => array ('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01','modified' => '2006-11-30 18:38:10')),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Child' => array(
|
||||
array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2',
|
||||
'Apple' => array ('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10')),
|
||||
'Child' => array(array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array()),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array('id' => 1, 'apple_id' => 3, 'name' => 'sample1')),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3')))),
|
||||
'Apple' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10')),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array('id' => 1, 'apple_id' => 3, 'name' => 'sample1')),
|
||||
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3'),
|
||||
'Child' => array(
|
||||
array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'))))),
|
||||
array('Apple' => array(
|
||||
'id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26')),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 1, 'apple_id' => 3, 'name' => 'sample1',
|
||||
'Apple' => array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24')),
|
||||
'Child' => array()),
|
||||
array('Apple' => array(
|
||||
'id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26')),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3',
|
||||
'Apple' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36')),
|
||||
'Child' => array(array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39',
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Sample' => array()))),
|
||||
'Child' => array(
|
||||
array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39',
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'))))),
|
||||
array('Apple' => array(
|
||||
'id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16',
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16')),
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Child' => array(
|
||||
array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'))),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4',
|
||||
'Apple' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16')),
|
||||
'Child' => array(array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16',
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4')))),
|
||||
'Child' => array(
|
||||
array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16',
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4'),
|
||||
'Child' => array(
|
||||
array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'))))),
|
||||
array('Apple' => array(
|
||||
'id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'),
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10')),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Child' => array(
|
||||
array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => ''),
|
||||
'Child' => array(array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21',
|
||||
'Parent' => array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'),
|
||||
'Sample' => array()))),
|
||||
'Child' => array(
|
||||
array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21',
|
||||
'Parent' => array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'),
|
||||
'Sample' => array()))),
|
||||
array('Apple' => array(
|
||||
'id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'),
|
||||
'Parent' => array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39',
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36')),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => ''),
|
||||
'Child' => array()));
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Child' => array(
|
||||
array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => ''),
|
||||
'Child' => array()));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->model =& new Apple();
|
||||
$this->model->recursive = 2;
|
||||
|
||||
$result = $this->model->Parent->unbindModel(array('hasOne' => array('Sample')));
|
||||
$this->assertTrue($result);
|
||||
|
||||
|
@ -2688,49 +2758,66 @@ class ModelTest extends CakeTestCase {
|
|||
|
||||
$result = $this->model->findAll();
|
||||
$expected = array(array('Apple' => array (
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04','modified' => '2006-12-01 13:31:26'),
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26')),
|
||||
'Sample' => array('id' => '','apple_id' => '','name' => '')),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' =>'', 'apple_id' => '', 'name' => '')),
|
||||
array('Apple' => array(
|
||||
'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Parent' => array ('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01','modified' => '2006-11-30 18:38:10')),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Child' => array(
|
||||
array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2',
|
||||
'Apple' => array ('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
'Apple' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
array('Apple' => array(
|
||||
'id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26')),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 1, 'apple_id' => 3, 'name' => 'sample1',
|
||||
'Apple' => array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'))),
|
||||
array('Apple' => array(
|
||||
'id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26')),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3',
|
||||
'Apple' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
array('Apple' => array(
|
||||
'id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16',
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16')),
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Child' => array(
|
||||
array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'))),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4',
|
||||
'Apple' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'))),
|
||||
array('Apple' => array(
|
||||
'id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'),
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10')),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Child' => array(
|
||||
array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => '')),
|
||||
array('Apple' => array(
|
||||
'id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'),
|
||||
'Parent' => array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39',
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36')),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => '')));
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Child' => array(
|
||||
array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => '')));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->model =& new Apple();
|
||||
$this->model->recursive = 2;
|
||||
|
||||
$result = $this->model->unbindModel(array('hasMany' => array('Child')));
|
||||
$this->assertTrue($result);
|
||||
|
||||
|
@ -2739,47 +2826,67 @@ class ModelTest extends CakeTestCase {
|
|||
|
||||
$result = $this->model->findAll();
|
||||
$expected = array(array('Apple' => array (
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04','modified' => '2006-12-01 13:31:26'),
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array('id' => 2,'apple_id' => 2,'name' => 'sample2')),
|
||||
'Sample' => array('id' => '','apple_id' => '','name' => '')),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' =>'', 'apple_id' => '', 'name' => '')),
|
||||
array('Apple' => array(
|
||||
'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Parent' => array ('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01','modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array()),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2')),
|
||||
array('Apple' => array(
|
||||
'id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array( 'id' => 2, 'apple_id' => 2, 'name' => 'sample2')),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 1, 'apple_id' => 3, 'name' => 'sample1')),
|
||||
array('Apple' => array(
|
||||
'id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2')),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3')),
|
||||
array('Apple' => array(
|
||||
'id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16',
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4')),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4'),
|
||||
'Child' => array(
|
||||
array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'))),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4')),
|
||||
array('Apple' => array(
|
||||
'id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'),
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36',
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Sample' => array( 'id' => 3, 'apple_id' => 6, 'name' => 'sample3')),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3'),
|
||||
'Child' => array(
|
||||
array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => '')),
|
||||
array('Apple' => array(
|
||||
'id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'),
|
||||
'Parent' => array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39',
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Sample' => array()),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => '')));
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => '')));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->model->Parent->unbindModel(array('belongsTo' => array('Parent')));
|
||||
|
@ -2790,44 +2897,64 @@ class ModelTest extends CakeTestCase {
|
|||
|
||||
$result = $this->model->findAll();
|
||||
$expected = array(array('Apple' => array (
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04','modified' => '2006-12-01 13:31:26'),
|
||||
'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Sample' => array('id' => 2,'apple_id' => 2,'name' => 'sample2')),
|
||||
'Sample' => array('id' => '','apple_id' => '','name' => '')),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' =>'', 'apple_id' => '', 'name' => '')),
|
||||
array('Apple' => array(
|
||||
'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'),
|
||||
'Parent' => array ('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Sample' => array()),
|
||||
'Parent' => array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26',
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2',
|
||||
'Apple' => array ('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
'Apple' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10'))),
|
||||
array('Apple' => array(
|
||||
'id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Sample' => array( 'id' => 2, 'apple_id' => 2, 'name' => 'sample2')),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 1, 'apple_id' => 3, 'name' => 'sample1',
|
||||
'Apple' => array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'))),
|
||||
array('Apple' => array(
|
||||
'id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'),
|
||||
'Parent' => array('id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10',
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2')),
|
||||
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
|
||||
'Child' => array(
|
||||
array('id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26'),
|
||||
array('id' => 3, 'apple_id' => 2, 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24'),
|
||||
array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3',
|
||||
'Apple' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36'))),
|
||||
array('Apple' => array(
|
||||
'id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'),
|
||||
'Parent' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16',
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4')),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4'),
|
||||
'Child' => array(
|
||||
array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'))),
|
||||
'Sample' => array('id' => 4, 'apple_id' => 7, 'name' => 'sample4',
|
||||
'Apple' => array('id' => 7, 'apple_id' => 7, 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16'))),
|
||||
array('Apple' => array(
|
||||
'id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'),
|
||||
'Parent' => array('id' => 6, 'apple_id' => 2, 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36',
|
||||
'Sample' => array( 'id' => 3, 'apple_id' => 6, 'name' => 'sample3')),
|
||||
'Sample' => array('id' => 3, 'apple_id' => 6, 'name' => 'sample3'),
|
||||
'Child' => array(
|
||||
array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => '')),
|
||||
array('Apple' => array(
|
||||
'id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'),
|
||||
'Parent' => array('id' => 8, 'apple_id' => 6, 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39',
|
||||
'Sample' => array()),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => '')));
|
||||
'Sample' => array(),
|
||||
'Child' => array(
|
||||
array('id' => 9, 'apple_id' => 8, 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21'))),
|
||||
'Sample' => array('id' => '', 'apple_id' => '', 'name' => '')));
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,10 +127,10 @@ class CakeTestCase extends UnitTestCase {
|
|||
|
||||
foreach ($classRegistry->__map as $key => $name) {
|
||||
$object =& $classRegistry->getObject(Inflector::camelize($key));
|
||||
if (is_subclass_of($object, 'Model') && ((is_array($params['fixturize']) && in_array($object->name, $params['fixturize'])) || $params['fixturize'] === true)) {
|
||||
$models[$object->name] = array (
|
||||
if (is_subclass_of($object, 'Model') && ((is_array($params['fixturize']) && in_array($object->currentModel, $params['fixturize'])) || $params['fixturize'] === true)) {
|
||||
$models[$object->currentModel] = array (
|
||||
'table' => $object->table,
|
||||
'model' => $object->name,
|
||||
'model' => $object->currentModel,
|
||||
'key' => Inflector::camelize($key)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ class CakeTestFixture extends Object {
|
|||
$query = array(
|
||||
'fields' => array_keys($this->fields),
|
||||
'table' => $db->name($model->table),
|
||||
'alias' => $model->name,
|
||||
'alias' => $model->currentModel,
|
||||
'conditions' => array(),
|
||||
'order' => null,
|
||||
'limit' => null
|
||||
|
@ -101,10 +101,10 @@ class CakeTestFixture extends Object {
|
|||
$query['fields'][$index] = $db->name($query['alias']) . '.' . $db->name($field);
|
||||
}
|
||||
|
||||
$records = $db->fetchAll($db->buildStatement($query, $model), false, $model->name);
|
||||
$records = $db->fetchAll($db->buildStatement($query, $model), false, $model->currentModel);
|
||||
|
||||
if ($records !== false && !empty($records)) {
|
||||
$this->records = Set::extract($records, '{n}.' . $model->name);
|
||||
$this->records = Set::extract($records, '{n}.' . $model->currentModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue