\n";
+ echo "\t\t | \n";
}
?>
";?> |
@@ -160,7 +160,7 @@ echo "\t>\n";
foreach ($otherFields as $field) {
- echo "\t\t\t | \n";
+ echo "\t\t\t | \n";
}
echo "\t\t\t\n";
diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php
index 37110fec3..636930674 100644
--- a/cake/libs/controller/components/acl.php
+++ b/cake/libs/controller/components/acl.php
@@ -272,7 +272,7 @@ class DB_ACL extends AclBase {
return false;
}
- $permKeys = $this->_getAcoKeys($this->Aro->Permission->loadInfo());
+ $permKeys = $this->_getAcoKeys($this->Aro->Permission->schema());
$aroPath = $this->Aro->node($aro);
$acoPath = new Set($this->Aco->node($aco));
@@ -349,7 +349,7 @@ class DB_ACL extends AclBase {
*/
function allow($aro, $aco, $actions = "*", $value = 1) {
$perms = $this->getAclLink($aro, $aco);
- $permKeys = $this->_getAcoKeys($this->Aro->Permission->loadInfo());
+ $permKeys = $this->_getAcoKeys($this->Aro->Permission->schema());
$save = array();
if ($perms == false) {
@@ -362,7 +362,7 @@ class DB_ACL extends AclBase {
}
if ($actions == "*") {
- $permKeys = $this->_getAcoKeys($this->Aro->Permission->loadInfo());
+ $permKeys = $this->_getAcoKeys($this->Aro->Permission->schema());
foreach ($permKeys as $key) {
$save[$key] = $value;
@@ -477,8 +477,7 @@ class DB_ACL extends AclBase {
*/
function _getAcoKeys($keys) {
$newKeys = array();
- $keys = $keys->extract('{n}.name');
-
+ $keys = array_keys($keys);
foreach ($keys as $key) {
if (!in_array($key, array('id', 'aro_id', 'aco_id'))) {
$newKeys[] = $key;
diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php
index b5eadce7e..8ccaa0cc3 100644
--- a/cake/libs/controller/controller.php
+++ b/cake/libs/controller/controller.php
@@ -365,7 +365,7 @@ class Controller extends Object {
* @access public
*/
function loadModel($modelClass = null, $id = false) {
- if($modelClass === null) {
+ if ($modelClass === null) {
$modelClass = $this->modelClass;
}
$cached = false;
@@ -817,7 +817,7 @@ class Controller extends Object {
$modelClass = $this->modelClass;
}
$fields = $this->{$modelClass}->schema();
- foreach ($fields->value as $field => $value) {
+ foreach ($fields as $field => $value) {
if (in_array($value['type'], array('datetime', 'timestamp', 'date', 'time'))) {
$useNewDate = false;
$date = array();
@@ -868,7 +868,7 @@ class Controller extends Object {
$time = join(':', array_values($time));
}
- if($date && $time) {
+ if ($date && $time) {
$date = $date . ' ' . $time;
} elseif (is_string($time)) {
$date = $time;
diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php
index 2267cc99b..5fbc65813 100644
--- a/cake/libs/controller/scaffold.php
+++ b/cake/libs/controller/scaffold.php
@@ -143,10 +143,8 @@ class Scaffold extends Object {
$var = $this->__passedVars[$j];
$this->{$var} = $controller->{$var};
}
+
$this->redirect = array('action'=> 'index');
- if (!is_null($this->plugin)) {
- $this->redirect = '/' . $this->plugin . '/' . $this->viewPath;
- }
if (!in_array('Form', $this->controller->helpers)) {
$this->controller->helpers[] = 'Form';
@@ -180,7 +178,7 @@ class Scaffold extends Object {
$pluralVar = Inflector::variable($this->controller->name);
$singularHumanName = Inflector::humanize($modelClass);
$pluralHumanName = Inflector::humanize($this->controller->name);
- $fields = $this->ScaffoldModel->_tableInfo->value;
+ $fields = array_keys($this->ScaffoldModel->schema());
$foreignKeys = $this->ScaffoldModel->keyToTable;
$belongsTo = $this->ScaffoldModel->belongsTo;
$hasOne = $this->ScaffoldModel->hasOne;
diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php
index df106ec6b..4e2125090 100644
--- a/cake/libs/debugger.php
+++ b/cake/libs/debugger.php
@@ -440,4 +440,4 @@ if (!defined('DISABLE_DEFAULT_ERROR_HANDLING')) {
Debugger::invoke(Debugger::getInstance());
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php
index 0b036df07..159fc4283 100644
--- a/cake/libs/model/behaviors/tree.php
+++ b/cake/libs/model/behaviors/tree.php
@@ -728,4 +728,4 @@ class TreeBehavior extends ModelBehavior {
$model->updateAll(array($field => $field . ' ' . $dir . ' ' . $shift), $conditions);
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/libs/model/datasources/dbo/dbo_adodb.php b/cake/libs/model/datasources/dbo/dbo_adodb.php
index 716b978b5..133d76dbc 100644
--- a/cake/libs/model/datasources/dbo/dbo_adodb.php
+++ b/cake/libs/model/datasources/dbo/dbo_adodb.php
@@ -346,9 +346,7 @@ class DboAdodb extends DboSource {
}
$fields = array_map('trim', $fields);
} else {
- foreach ($model->_tableInfo->value as $field) {
- $fields[] = $field['name'];
- }
+ $fields = array_keys($model->schema());
}
}
diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php
index 1bf78ac0d..369479726 100644
--- a/cake/libs/model/datasources/dbo_source.php
+++ b/cake/libs/model/datasources/dbo_source.php
@@ -727,8 +727,8 @@ class DboSource extends DataSource {
$with = $model->hasAndBelongsToMany[$association]['with'];
$foreignKey = $model->hasAndBelongsToMany[$association]['foreignKey'];
- $habtmFields = $model->{$with}->loadInfo();
- $habtmFields = $habtmFields->extract('{n}.name');
+ $habtmFields = $model->{$with}->schema();
+ $habtmFields = array_keys($habtmFields);
$habtmFieldsCount = count($habtmFields);
$q = $this->insertQueryData($query, null, $association, $assocData, $model, $linkModel, $stack);
@@ -774,7 +774,7 @@ class DboSource extends DataSource {
if ($type == 'hasAndBelongsToMany') {
$merge = array();
foreach($fetch as $j => $data) {
- if(isset($data[$with]) && $data[$with][$foreignKey] === $row[$model->alias][$model->primaryKey]) {
+ if (isset($data[$with]) && $data[$with][$foreignKey] === $row[$model->alias][$model->primaryKey]) {
if ($habtmFieldsCount > 2) {
$merge[] = $data;
} else {
@@ -1130,9 +1130,8 @@ class DboSource extends DataSource {
$joinAlias = $joinTbl;
if (isset($assocData['with']) && !empty($assocData['with'])) {
- $joinFields = $model->{$assocData['with']}->loadInfo();
- $joinFields = $joinFields->extract('{n}.name');
-
+ $joinFields = $model->{$assocData['with']}->schema();
+ $joinFields = array_keys($joinFields);
if (is_array($joinFields) && !empty($joinFields)) {
$joinFields = $this->fields($model->{$assocData['with']}, $model->{$assocData['with']}->alias, $joinFields);
$joinAssoc = $joinAlias = $model->{$assocData['with']}->alias;
@@ -1433,11 +1432,11 @@ class DboSource extends DataSource {
}
}
if (empty($fields)) {
- $fieldData = $model->loadInfo();
- $fields = $fieldData->extract('{n}.name');
+ $fields = array_keys($model->schema());
} else {
$fields = array_filter($fields);
}
+
if (!$quote) {
return $fields;
}
@@ -1918,9 +1917,9 @@ class DboSource extends DataSource {
if (isset($col['key']) && $col['key'] == 'primary') {
$primary = $name;
}
- if($name !== 'indexes') {
+ if ($name !== 'indexes') {
$col['name'] = $name;
- if(!isset($col['type'])) {
+ if (!isset($col['type'])) {
$col['type'] = 'string';
}
$cols[] = $this->buildColumn($col);
@@ -1928,7 +1927,7 @@ class DboSource extends DataSource {
$index[] = $this->buildIndex($col);
}
}
- if(empty($index) && !empty($primary)) {
+ if (empty($index) && !empty($primary)) {
$col = array('PRIMARY' => array('column'=> $primary, 'unique' => 1));
$index[] = $this->buildIndex($col);
}
@@ -2031,4 +2030,4 @@ class DboSource extends DataSource {
return false;
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/libs/model/db_acl.php b/cake/libs/model/db_acl.php
index 6dab10a87..054440fe3 100644
--- a/cake/libs/model/db_acl.php
+++ b/cake/libs/model/db_acl.php
@@ -285,4 +285,4 @@ class Permission extends AppModel {
parent::__construct();
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php
index 3f707708e..f541679c2 100644
--- a/cake/libs/model/model.php
+++ b/cake/libs/model/model.php
@@ -653,7 +653,7 @@ class Model extends Overloadable {
}
$duplicate = false;
- if(ClassRegistry::isKeySet($colKey)) {
+ if (ClassRegistry::isKeySet($colKey)) {
$model = ClassRegistry::getObject($colKey);
if (is_a($model, $className)) {
$duplicate = true;
@@ -751,8 +751,8 @@ class Model extends Overloadable {
$this->{$type}[$assocKey]['joinTable'] = $this->{$joinClass}->table;
}
- if (count($this->{$joinClass}->_schema->value) > 2) {
- if (isset($this->{$joinClass}->_schema->value['id'])) {
+ if (count($this->{$joinClass}->_schema) > 2) {
+ if (isset($this->{$joinClass}->_schema['id'])) {
$this->{$joinClass}->primaryKey = 'id';
}
}
@@ -777,12 +777,11 @@ class Model extends Overloadable {
'table' => $this->tablePrefix . $tableName)));
}
- $this->_tableInfo = null;
$this->_schema = null;
}
$this->table = $this->useTable = $tableName;
$this->tableToModel[$this->table] = $this->alias;
- $this->loadInfo();
+ $this->schema();
}
/**
* This function does two things: 1) it scans the array $one for the primary key,
@@ -839,13 +838,13 @@ class Model extends Overloadable {
* @return array Array of table metadata
*/
function schema($clear = false) {
- if (!is_object($this->_schema) || $clear) {
+ if (!is_array($this->_schema) || $clear) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$db->cacheSources = $this->cacheSources;
if ($db->isInterfaceSupported('describe') && $this->useTable !== false) {
- $this->_schema = new Set($db->describe($this, $clear));
+ $this->_schema = $db->describe($this, $clear);
} elseif ($this->useTable === false) {
- $this->_schema = new Set();
+ $this->_schema = array();
}
}
return $this->_schema;
@@ -856,16 +855,15 @@ class Model extends Overloadable {
* @deprecated
*/
function loadInfo($clear = false) {
- if (!is_object($this->_tableInfo) || $clear) {
- $info = $this->schema($clear);
+ $info = $this->schema($clear);
+ if (is_array($info)) {
$fields = array();
- foreach($info->value as $field => $value) {
+ foreach($info as $field => $value) {
$fields[] = am(array('name'=> $field), $value);
}
unset($info);
- $this->_tableInfo = new Set($fields);
+ return new Set($fields);
}
- return $this->_tableInfo;
}
/**
* Returns an associative array of field names and column types.
@@ -873,13 +871,15 @@ class Model extends Overloadable {
* @return array
*/
function getColumnTypes() {
- $columns = $this->loadInfo();
- $names = $columns->extract('{n}.name');
- $types = $columns->extract('{n}.type');
- if (!count($names) || !count($types)) {
- trigger_error(__('(Model::getColumnTypes) Unable to build model field data. If you are using a model without a database table, try implementing loadInfo()', true), E_USER_WARNING);
+ $columns = $this->schema();
+ if (empty($columns)) {
+ trigger_error(__('(Model::getColumnTypes) Unable to build model field data. If you are using a model without a database table, try implementing schema()', true), E_USER_WARNING);
}
- return array_combine($names, $types);
+ $cols = array();
+ foreach ($columns as $field => $values) {
+ $cols[$field] = $values['type'];
+ }
+ return $cols;
}
/**
* Returns the column type of a column in the model
@@ -888,9 +888,12 @@ class Model extends Overloadable {
* @return string Column type
*/
function getColumnType($column) {
- $cols = $this->getColumnTypes();
- if (isset($cols[$column])) {
- return $cols[$column];
+ $cols = $this->schema();
+ if (empty($cols)) {
+ trigger_error(__('(Model::getColumnType) Unable to locate model field data. If you are using a model without a database table, try implementing schema()', true), E_USER_WARNING);
+ }
+ if (isset($cols[$column]['type'])) {
+ return $cols[$column]['type'];
}
return null;
}
@@ -910,12 +913,12 @@ class Model extends Overloadable {
return false;
}
- if (empty($this->_tableInfo)) {
- $this->loadInfo();
+ if (empty($this->_schema)) {
+ $this->schema();
}
- if ($this->_tableInfo != null) {
- return in_array($name, $this->_tableInfo->extract('{n}.name'));
+ if ($this->_schema != null) {
+ return isset($this->_schema[$name]);
}
return false;
}
@@ -929,20 +932,12 @@ class Model extends Overloadable {
$this->id = false;
$this->data = array();
$defaults = array();
-
- $cols = $this->loadInfo();
- $names = $cols->extract('{n}.name');
- $values = $cols->extract('{n}.default');
-
- if (!empty($names) && !empty($values)) {
- $count = count($names);
- for ($i = 0; $i < $count; $i++) {
- if ($names[$i] != $this->primaryKey) {
- $defaults[$names[$i]] = $values[$i];
- }
+ $fields = $this->schema();
+ foreach ($fields as $field => $properties) {
+ if ($this->primaryKey !== $field && isset($properties['default'])) {
+ $defaults[$field] = $properties['default'];
}
}
-
$this->validationErrors = array();
$this->set(Set::filter($defaults));
$this->set($data);
@@ -1126,9 +1121,10 @@ class Model extends Overloadable {
$success = false;
}
} else {
- foreach ($this->_tableInfo->value as $key => $value) {
- if (in_array($this->primaryKey, $value)) {
- if (empty($this->data[$this->alias][$this->primaryKey]) && $this->_tableInfo->value[$key]['type'] === 'string' && $this->_tableInfo->value[$key]['length'] === 36) {
+
+ foreach ($this->_schema as $field => $properties) {
+ if ($this->primaryKey === $field) {
+ if (empty($this->data[$this->alias][$this->primaryKey]) && $this->_schema[$field]['type'] === 'string' && $this->_schema[$field]['length'] === 36) {
$fields[] = $this->primaryKey;
$values[] = String::uuid();
}
@@ -1164,7 +1160,7 @@ class Model extends Overloadable {
}
}
$this->afterSave($created);
- if(!empty($this->data)) {
+ if (!empty($this->data)) {
$success = $this->data;
}
$this->data = false;
diff --git a/cake/libs/model/schema.php b/cake/libs/model/schema.php
index 8d20923e5..00caebda7 100644
--- a/cake/libs/model/schema.php
+++ b/cake/libs/model/schema.php
@@ -141,7 +141,7 @@ class CakeSchema extends Object {
if (file_exists($path . DS . $file)) {
require_once($path . DS . $file);
$class = $name .'Schema';
- if(class_exists($class)) {
+ if (class_exists($class)) {
$Schema =& new $class();
$this->_build($options);
return $Schema;
@@ -171,32 +171,32 @@ class CakeSchema extends Object {
loadModel(null);
$tables = array();
$currentTables = $db->sources();
- if(isset($db->config['prefix'])) {
+ if (isset($db->config['prefix'])) {
$prefix = $db->config['prefix'];
}
if (empty($models) && $models !== false) {
$models = Configure::listObjects('model');
}
- if(is_array($models)) {
+ if (is_array($models)) {
foreach ($models as $model) {
if (!class_exists($model)) {
loadModel($model);
}
- if(class_exists($model)) {
+ if (class_exists($model)) {
$Object =& new $model();
$Object->setDataSource($connection);
$table = $db->fullTableName($Object, false);
if (is_object($Object)) {
$table = $db->fullTableName($Object, false);
- if(in_array($table, $currentTables)) {
+ if (in_array($table, $currentTables)) {
$key = array_search($table, $currentTables);
- if(empty($tables[$Object->table])) {
+ if (empty($tables[$Object->table])) {
$tables[$Object->table] = $this->__columns($Object);
$tables[$Object->table]['indexes'] = $db->index($Object);
unset($currentTables[$key]);
}
- if(!empty($Object->hasAndBelongsToMany)) {
+ if (!empty($Object->hasAndBelongsToMany)) {
foreach($Object->hasAndBelongsToMany as $Assoc => $assocData) {
if (isset($assocData['with'])) {
$class = $assocData['with'];
@@ -205,7 +205,7 @@ class CakeSchema extends Object {
}
if (is_object($Object->$class)) {
$table = $db->fullTableName($Object->$class, false);
- if(in_array($table, $currentTables)) {
+ if (in_array($table, $currentTables)) {
$key = array_search($table, $currentTables);
$tables[$Object->$class->table] = $this->__columns($Object->$class);
$tables[$Object->$class->table]['indexes'] = $db->index($Object->$class);
@@ -219,13 +219,13 @@ class CakeSchema extends Object {
}
}
}
- if(!empty($currentTables)) {
+ if (!empty($currentTables)) {
foreach($currentTables as $table) {
- if($prefix) {
+ if ($prefix) {
$table = str_replace($prefix, '', $table);
}
$Object = new AppModel(array('name'=> Inflector::classify($table), 'table'=> $table, 'ds'=> $connection));
- if(in_array($table, array('aros', 'acos', 'aros_acos', Configure::read('Session.table'), 'i18n'))) {
+ if (in_array($table, array('aros', 'acos', 'aros_acos', Configure::read('Session.table'), 'i18n'))) {
$tables[$Object->table] = $this->__columns($Object);
$tables[$Object->table]['indexes'] = $db->index($Object);
} else {
@@ -279,17 +279,17 @@ class CakeSchema extends Object {
$out .= "\tfunction before(\$event = array()) {\n\t\treturn true;\n\t}\n\n\tfunction after(\$event = array()) {\n\t}\n\n";
- if(empty($tables)) {
+ if (empty($tables)) {
$this->read();
}
foreach ($tables as $table => $fields) {
- if(!is_numeric($table) && $table !== 'missing') {
+ if (!is_numeric($table) && $table !== 'missing') {
$out .= "\tvar \${$table} = array(\n";
if (is_array($fields)) {
$cols = array();
foreach ($fields as $field => $value) {
- if($field != 'indexes') {
+ if ($field != 'indexes') {
if (is_string($value)) {
$type = $value;
$value = array('type'=> $type);
@@ -354,7 +354,7 @@ class CakeSchema extends Object {
}
$tables = array();
foreach ($new as $table => $fields) {
- if($table == 'missing') {
+ if ($table == 'missing') {
break;
}
if (!array_key_exists($table, $old)) {
@@ -398,9 +398,9 @@ class CakeSchema extends Object {
*/
function __values($values) {
$vals = array();
- if(is_array($values)) {
+ if (is_array($values)) {
foreach ($values as $key => $val) {
- if(is_array($val)) {
+ if (is_array($val)) {
$vals[] = "'{$key}' => array('".join("', '", $val)."')";
} else if (!is_numeric($key)) {
$prop = "'{$key}' => ";
@@ -430,7 +430,7 @@ class CakeSchema extends Object {
$db =& ConnectionManager::getDataSource($Obj->useDbConfig);
$fields = $Obj->schema(true);
$columns = $props = array();
- foreach ($fields->value as $name => $value) {
+ foreach ($fields as $name => $value) {
if ($Obj->primaryKey == $name) {
$value['key'] = 'primary';
diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php
index 498c6423b..01f47831c 100644
--- a/cake/libs/view/helpers/form.php
+++ b/cake/libs/view/helpers/form.php
@@ -43,12 +43,12 @@ class FormHelper extends AppHelper {
*/
var $helpers = array('Html');
/**
- * Holds the fields array('field_name' => 'type'), sizes array('field_name' => 'size'),
+ * Holds the fields array('field_name' => array('type'=> 'string', 'length'=> 100),
* primaryKey and validates array('field_name')
*
* @access public
*/
- var $fieldset = array('fields' => array(), 'sizes' => array(), 'key' => 'id', 'validates' => array());
+ var $fieldset = array('fields' => array(), 'key' => 'id', 'validates' => array());
/**
* Enter description here...
*
@@ -119,19 +119,12 @@ class FormHelper extends AppHelper {
$created = $id = false;
if (isset($object)) {
- $fields = $object->loadInfo();
- $fieldNames = $fields->extract('{n}.name');
- $fieldTypes = $fields->extract('{n}.type');
- $fieldLengths = $fields->extract('{n}.length');
- if (!count($fieldNames) || !count($fieldTypes)) {
- trigger_error(__('(FormHelper::create) Unable to use model field data. If you are using a model without a database table, try implementing loadInfo()', true), E_USER_WARNING);
- }
- if (!count($fieldNames) || !count($fieldLengths) || (count($fieldNames) != count($fieldTypes))) {
- trigger_error(__('(FormHelper::create) Unable to use model field data. If you are using a model without a database table, try implementing loadInfo()', true), E_USER_WARNING);
+ $fields = $object->schema();
+ if (empty($fields)) {
+ trigger_error(__('(FormHelper::create) Unable to use model field data. If you are using a model without a database table, try implementing schema()', true), E_USER_WARNING);
}
$data = array(
- 'fields' => array_combine($fieldNames, $fieldTypes),
- 'sizes' => array_combine($fieldNames, $fieldLengths),
+ 'fields' => $fields,
'key' => $object->primaryKey,
'validates' => (ife(empty($object->validate), array(), array_keys($object->validate)))
);
@@ -498,7 +491,7 @@ class FormHelper extends AppHelper {
} elseif (in_array($this->field(), array('psword', 'passwd', 'password'))) {
$options['type'] = 'password';
} elseif (isset($this->fieldset['fields'][$this->field()])) {
- $type = $this->fieldset['fields'][$this->field()];
+ $type = $this->fieldset['fields'][$this->field()]['type'];
$primaryKey = $this->fieldset['key'];
} elseif (ClassRegistry::isKeySet($this->model())) {
$model =& ClassRegistry::getObject($this->model());
@@ -543,8 +536,8 @@ class FormHelper extends AppHelper {
}
if (!array_key_exists('maxlength', $options) && $options['type'] == 'text') {
- if (isset($this->fieldset['sizes'][$this->field()])) {
- $options['maxlength'] = $this->fieldset['sizes'][$this->field()];
+ if (isset($this->fieldset['fields'][$this->field()]['length'])) {
+ $options['maxlength'] = $this->fieldset['fields'][$this->field()]['length'];
}
}
@@ -1449,4 +1442,4 @@ class FormHelper extends AppHelper {
return $this->__options[$name];
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php
index 4158271ca..6ecc8e720 100644
--- a/cake/libs/view/helpers/html.php
+++ b/cake/libs/view/helpers/html.php
@@ -725,4 +725,4 @@ class HtmlHelper extends AppHelper {
}
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/libs/view/templates/scaffolds/index.ctp b/cake/libs/view/templates/scaffolds/index.ctp
index 14e1a6e19..6fb43bc2d 100644
--- a/cake/libs/view/templates/scaffolds/index.ctp
+++ b/cake/libs/view/templates/scaffolds/index.ctp
@@ -34,7 +34,7 @@ echo $paginator->counter(array(
- sort("{$field['name']}");?> |
+ sort("{$field}");?> |
|
@@ -47,15 +47,14 @@ foreach (${$pluralVar} as ${$singularVar}):
}
echo "\n";
echo "\t\n";
-
foreach ($fields as $field) {
- if (in_array($field['name'], array_keys($foreignKeys))) {
- $otherModelClass = $foreignKeys[$field['name']][1];
+ if (in_array($field, array_keys($foreignKeys))) {
+ $otherModelClass = $foreignKeys[$field][1];
$otherModelKey = Inflector::underscore($otherModelClass);
$otherControllerName = Inflector::pluralize($otherModelClass);
$otherControllerPath = Inflector::underscore($otherControllerName);
- if (isset($foreignKeys[$field['name']][2])) {
- $otherModelClass = $foreignKeys[$field['name']][2];
+ if (isset($foreignKeys[$field][2])) {
+ $otherModelClass = $foreignKeys[$field][2];
}
$otherVariableName = Inflector::variable($otherModelClass);
$otherModelObj =& ClassRegistry::getObject($otherModelKey);
@@ -63,7 +62,7 @@ echo "\n";
$otherDisplayField = $otherModelObj->displayField;
echo "\t\t\n\t\t\t" . $html->link(${$singularVar}[$otherModelClass][$otherDisplayField], array('controller'=> $otherControllerPath, 'action'=>'view', ${$singularVar}[$otherModelClass][$otherPrimaryKey])) . "\n\t\t | \n";
} else {
- echo "\t\t\n\t\t\t" . ${$singularVar}[$modelClass][$field['name']] . " \n\t\t | \n";
+ echo "\t\t\n\t\t\t" . ${$singularVar}[$modelClass][$field] . " \n\t\t | \n";
}
}
diff --git a/cake/libs/view/templates/scaffolds/view.ctp b/cake/libs/view/templates/scaffolds/view.ctp
index f3bb15f9f..2b51e472d 100644
--- a/cake/libs/view/templates/scaffolds/view.ctp
+++ b/cake/libs/view/templates/scaffolds/view.ctp
@@ -35,13 +35,13 @@ foreach ($fields as $field) {
$class = ' class="altrow"';
}
- if (in_array($field['name'], array_keys($foreignKeys))) {
- $otherModelClass = $foreignKeys[$field['name']][1];
+ if (in_array($field, array_keys($foreignKeys))) {
+ $otherModelClass = $foreignKeys[$field][1];
$otherModelKey = Inflector::underscore($otherModelClass);
$otherControllerName = Inflector::pluralize($otherModelClass);
$otherControllerPath = Inflector::underscore($otherControllerName);
- if (isset($foreignKeys[$field['name']][2])) {
- $otherModelClass = $foreignKeys[$field['name']][2];
+ if (isset($foreignKeys[$field][2])) {
+ $otherModelClass = $foreignKeys[$field][2];
}
$otherSingularVar = Inflector::variable($otherModelClass);
$otherModelObj =& ClassRegistry::getObject($otherModelKey);
@@ -50,8 +50,8 @@ foreach ($fields as $field) {
echo "\t\t".Inflector::humanize($otherModelClass)."\n";
echo "\t\t\n\t\t\t".$html->link(${$singularVar}[$otherModelClass][$otherDisplayField], array('controller'=> $otherControllerPath, 'action'=>'view', ${$singularVar}[$otherModelClass][$otherPrimaryKey])). "\n\t\t\t \n\t\t\n";
} else {
- echo "\t\t".Inflector::humanize($field['name'])."\n";
- echo "\t\t\n\t\t\t" . ${$singularVar}[$modelClass][$field['name']] . "\n\t\t\t \n\t\t\n";
+ echo "\t\t".Inflector::humanize($field)."\n";
+ echo "\t\t\n\t\t\t" . ${$singularVar}[$modelClass][$field] . "\n\t\t\t \n\t\t\n";
}
}
?>
@@ -90,7 +90,7 @@ foreach ($hasOne as $assocName => $assocData):
$otherPluralHumanName = Inflector::humanize(Inflector::pluralize($assocKey));
$otherSingularHumanName = Inflector::humanize($assocKey);
$otherModelObj =& ClassRegistry::getObject($otherModelKey);
- $otherFields = $otherModelObj->_tableInfo->value;
+ $otherFields = array_keys($otherModelObj->schema());
$otherPrimaryKey = $otherModelObj->primaryKey;
?>
@@ -104,8 +104,8 @@ foreach ($hasOne as $assocName => $assocData):
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
- echo "\t\t ".Inflector::humanize($field['name'])."\n";
- echo "\t\t \n\t" .${$singularVar}[$assocName][$field['name']] ."\n \n";
+ echo "\t\t ".Inflector::humanize($field)."\n";
+ echo "\t\t \n\t" .${$singularVar}[$assocName][$field] ."\n \n";
}
?>
@@ -130,7 +130,7 @@ foreach ($relations as $assocName => $assocData):
$assocKey = Inflector::underscore($assocName);
$otherPluralHumanName = Inflector::humanize(Inflector::pluralize($assocKey));
$otherSingularHumanName = Inflector::humanize($assocKey);
- $otherFields = $otherModelObj->_tableInfo->value;
+ $otherFields = array_keys($otherModelObj->schema());;
$otherPrimaryKey = $otherModelObj->primaryKey;
?>
@@ -143,7 +143,7 @@ foreach ($relations as $assocName => $assocData):
".Inflector::humanize($field['name'])."\n";
+ echo "\t\t".Inflector::humanize($field)." | \n";
}
?>
Actions |
@@ -158,7 +158,7 @@ foreach ($relations as $assocName => $assocData):
echo "\t\t \n";
foreach ($otherFields as $field) {
- echo "\t\t\t".${$otherSingularVar}[$field['name']]." | \n";
+ echo "\t\t\t".${$otherSingularVar}[$field]." | \n";
}
echo "\t\t\t\n";
diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php
index fb691abb3..73568237b 100644
--- a/cake/tests/cases/dispatcher.test.php
+++ b/cake/tests/cases/dispatcher.test.php
@@ -687,4 +687,4 @@ class DispatcherTest extends UnitTestCase {
$_GET = $this->_get;
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php
index 9957cbf5b..d0d326569 100644
--- a/cake/tests/cases/libs/controller/components/auth.test.php
+++ b/cake/tests/cases/libs/controller/components/auth.test.php
@@ -336,4 +336,4 @@ class AuthTest extends CakeTestCase {
unset($this->Controller, $this->AuthUser);
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php
index b792d2191..dceab00c3 100644
--- a/cake/tests/cases/libs/controller/components/email.test.php
+++ b/cake/tests/cases/libs/controller/components/email.test.php
@@ -72,4 +72,4 @@ class EmailTest extends CakeTestCase {
}
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/model/behaviors/tree.test.php b/cake/tests/cases/libs/model/behaviors/tree.test.php
index b8033e802..d388d38ea 100644
--- a/cake/tests/cases/libs/model/behaviors/tree.test.php
+++ b/cake/tests/cases/libs/model/behaviors/tree.test.php
@@ -771,4 +771,4 @@ class NumberTreeCase extends CakeTestCase {
$this->assertEqual($total, $expects);
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
index e301c9286..222d2f652 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
@@ -72,7 +72,7 @@
}
function schema() {
- return new Set(array(
+ return array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
@@ -91,7 +91,7 @@
'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ );
}
}
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
index 1b65af3d9..6c1c76a51 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
@@ -72,7 +72,7 @@ class MysqlTestModel extends Model {
}
function schema() {
- return new Set(array(
+ return array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
@@ -91,7 +91,7 @@ class MysqlTestModel extends Model {
'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ );
}
}
/**
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
index 1eac0a692..b01d0d5f7 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
@@ -72,7 +72,7 @@ class PostgresTestModel extends Model {
}
function schema() {
- return new Set(array(
+ return array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
@@ -91,7 +91,7 @@ class PostgresTestModel extends Model {
'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ );
}
}
/**
diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
index 0cbfe69f5..ac12e1b61 100644
--- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
@@ -51,27 +51,30 @@ class TestModel extends CakeTestModel {
return $conditions;
}
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'client_id', 'type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'login', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'passwd', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
- array('name' => 'addr_1', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
- array('name' => 'addr_2', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
- array('name' => 'zip_code', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
- array('name' => 'city', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
- array('name' => 'country', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
- array('name' => 'phone', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
- array('name' => 'fax', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
- array('name' => 'url', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
- array('name' => 'email', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
- array('name' => 'comments', 'type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'last_login', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
+ 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
+ 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
+ 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
+ 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
+ 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
+ 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
+ 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
+ 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
+ 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
+ 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => '155'),
+ 'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
+ }
+ return $this->_schema;
}
}
/**
@@ -129,17 +132,16 @@ class TestModel4 extends CakeTestModel {
'associationForeignKey' => 'test_model7_id'
));
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
-
- return $this->_tableInfo;
+ return $this->_schema;
}
}
/**
@@ -163,18 +165,17 @@ class TestModel5 extends CakeTestModel {
'foreignKey' => 'test_model5_id'
));
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'test_model4_id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
-
- return $this->_tableInfo;
+ return $this->_schema;
}
}
/**
@@ -194,18 +195,17 @@ class TestModel6 extends CakeTestModel {
'foreignKey' => 'test_model5_id'
));
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'test_model5_id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'test_model5_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
-
- return $this->_tableInfo;
+ return $this->_schema;
}
}
/**
@@ -220,16 +220,16 @@ class TestModel7 extends CakeTestModel {
var $table = 'test_model7';
var $useTable = false;
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
}
/**
@@ -252,18 +252,17 @@ class TestModel8 extends CakeTestModel {
)
);
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'test_model9_id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'test_model9_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
-
- return $this->_tableInfo;
+ return $this->_schema;
}
}
/**
@@ -284,18 +283,17 @@ class TestModel9 extends CakeTestModel {
'conditions' => 'TestModel8.name != \'larry\''
));
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'test_model8_id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'test_model8_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
-
- return $this->_tableInfo;
+ return $this->_schema;
}
}
@@ -314,14 +312,14 @@ class Level extends CakeTestModel {
)
);
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
- array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '20')
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
+ 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'),
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
}
@@ -335,16 +333,17 @@ class Group extends CakeTestModel {
var $hasMany = array('Category2', 'User2');
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
- array('name' => 'level_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '20')
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
+ 'level_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
+ 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'),
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
+
}
class User2 extends CakeTestModel {
@@ -368,16 +367,16 @@ class User2 extends CakeTestModel {
),
);
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
- array('name' => 'group_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'level_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '20')
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
+ 'group_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
+ 'level_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
+ 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'),
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
}
@@ -409,18 +408,19 @@ class Category2 extends CakeTestModel {
'limit'=>'3')
);
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
- array('name' => 'group_id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
- array('name' => 'parent_id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
- array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '255'),
- array('name' => 'icon', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '255'),
- array('name' => 'description', 'text' => 'string', 'null' => false, 'default' => '', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
+ 'group_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
+ 'parent_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
+ 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'),
+ 'icon' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'),
+ 'description' => array('type' => 'text', 'null' => false, 'default' => '', 'length' => null),
+
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
}
@@ -438,31 +438,31 @@ class Article2 extends CakeTestModel {
)
);
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
- array('name' => 'category_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'user_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'rate_count', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'rate_sum', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'viewed', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'version', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '45'),
- array('name' => 'title', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '200'),
- array('name' => 'intro', 'text' => 'string', 'null' => true, 'default' => '', 'length' => null),
- array('name' => 'comments', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '4'),
- array('name' => 'body', 'text' => 'string', 'null' => true, 'default' => '', 'length' => null),
- array('name' => 'isdraft', 'type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
- array('name' => 'allow_comments', 'type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'),
- array('name' => 'moderate_comments', 'type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'),
- array('name' => 'published', 'type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
- array('name' => 'multipage', 'type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
- array('name' => 'published_date', 'type' => 'datetime', 'null' => true, 'default' => '', 'length' => null),
- array('name' => 'created', 'type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null),
- array('name' => 'modified', 'type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
+ 'category_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'rate_count' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'rate_sum' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'viewed' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'version' => array('type' => 'string', 'null' => true, 'default' => '', 'length' => '45'),
+ 'title' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '200'),
+ 'intro' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null),
+ 'comments' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '4'),
+ 'body' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null),
+ 'isdraft' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
+ 'allow_comments' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'),
+ 'moderate_comments' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'),
+ 'published' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
+ 'multipage' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
+ 'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null),
+ 'created' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null),
+ 'modified' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null)
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
}
@@ -471,17 +471,17 @@ class CategoryFeatured2 extends CakeTestModel {
var $table = 'category_featured';
var $useTable = false;
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
- array('name' => 'parent_id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
- array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '255'),
- array('name' => 'icon', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '255'),
- array('name' => 'description', 'text' => 'string', 'null' => false, 'default' => '', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
+ 'parent_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
+ 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'),
+ 'icon' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'),
+ 'description' => array('text' => 'string', 'null' => false, 'default' => '', 'length' => null)
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
}
@@ -497,16 +497,16 @@ class Featured2 extends CakeTestModel {
)
);
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
- array('name' => 'article_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'category_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '20')
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
+ 'article_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'category_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20')
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
}
@@ -516,16 +516,16 @@ class Comment2 extends CakeTestModel {
var $belongsTo = array('ArticleFeatured2', 'User2');
var $useTable = false;
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
- array('name' => 'article_featured_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'user_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'title', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '20')
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
+ 'article_featured_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20')
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
}
@@ -549,21 +549,21 @@ class ArticleFeatured2 extends CakeTestModel {
'Comment2' => array('className'=>'Comment2', 'dependent' => true)
);
- function loadInfo() {
- if (!isset($this->_tableInfo)) {
- $this->_tableInfo = new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
- array('name' => 'category_featured_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'user_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
- array('name' => 'title', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '200'),
- array('name' => 'body', 'text' => 'string', 'null' => true, 'default' => '', 'length' => null),
- array('name' => 'published', 'type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
- array('name' => 'published_date', 'type' => 'datetime', 'null' => true, 'default' => '', 'length' => null),
- array('name' => 'created', 'type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null),
- array('name' => 'modified', 'type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null)
- ));
+ function schema() {
+ if (!isset($this->_schema)) {
+ $this->_schema = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
+ 'category_featured_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'),
+ 'title' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'),
+ 'body' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null),
+ 'published' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'),
+ 'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null),
+ 'created' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null),
+ 'modified' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null)
+ );
}
- return $this->_tableInfo;
+ return $this->_schema;
}
}
@@ -645,7 +645,7 @@ class DboSourceTest extends UnitTestCase {
$this->assertPattern('/^SELECT\s+(.+)FROM(.+)`Category2`\.`group_id`\s+=\s+`Group`\.`id`\)\s+WHERE/', $query);
$this->model = new TestModel4();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'belongsTo', 'model' => 'TestModel4Parent');
@@ -698,7 +698,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBinding() {
$this->model = new TestModel8();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'hasOne', 'model' => 'TestModel9');
@@ -722,7 +722,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQuerySelfJoinWithConditionsInBelongsToBinding() {
$this->model = new TestModel9();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'belongsTo', 'model' => 'TestModel8');
@@ -746,7 +746,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQuerySelfJoinWithConditions() {
$this->model = new TestModel4();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'belongsTo', 'model' => 'TestModel4Parent');
@@ -767,7 +767,7 @@ class DboSourceTest extends UnitTestCase {
$this->assertPattern('/\s+WHERE\s+(?:\()?`TestModel4Parent`.`name`\s+!=\s+\'mariano\'(?:\))?\s*$/', $result);
$this->Featured2 = new Featured2();
- $this->Featured2->loadInfo();
+ $this->Featured2->schema();
$this->Featured2->bindModel(array(
'belongsTo' => array(
@@ -804,7 +804,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasOne() {
$this->model = new TestModel4();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'hasOne', 'model' => 'TestModel5');
@@ -831,7 +831,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasOneWithConditions() {
$this->model = new TestModel4();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'hasOne', 'model' => 'TestModel5');
@@ -855,7 +855,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryBelongsTo() {
$this->model = new TestModel5();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type'=>'belongsTo', 'model'=>'TestModel4');
@@ -881,7 +881,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryBelongsToWithConditions() {
$this->model = new TestModel5();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'belongsTo', 'model' => 'TestModel4');
@@ -907,7 +907,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasMany() {
$this->model = new TestModel5();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'hasMany', 'model' => 'TestModel6');
@@ -930,7 +930,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasManyWithLimit() {
$this->model = new TestModel5();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$this->model->hasMany['TestModel6']['limit'] = 2;
@@ -960,7 +960,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasManyWithConditions() {
$this->model = new TestModel5();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'hasMany', 'model' => 'TestModel6');
@@ -983,7 +983,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasManyWithOffsetAndLimit() {
$this->model = new TestModel5();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$__backup = $this->model->hasMany['TestModel6'];
@@ -1014,7 +1014,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasManyWithPageAndLimit() {
$this->model = new TestModel5();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$__backup = $this->model->hasMany['TestModel6'];
@@ -1045,7 +1045,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasManyWithFields() {
$this->model = new TestModel5();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'hasMany', 'model' => 'TestModel6');
@@ -1165,7 +1165,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasAndBelongsToMany() {
$this->model = new TestModel4();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7');
@@ -1190,7 +1190,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasAndBelongsToManyWithConditions() {
$this->model = new TestModel4();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7');
@@ -1213,7 +1213,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasAndBelongsToManyWithOffsetAndLimit() {
$this->model = new TestModel4();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$__backup = $this->model->hasAndBelongsToMany['TestModel7'];
@@ -1245,7 +1245,7 @@ class DboSourceTest extends UnitTestCase {
function testGenerateAssociationQueryHasAndBelongsToManyWithPageAndLimit() {
$this->model = new TestModel4();
- $this->model->loadInfo();
+ $this->model->schema();
$this->_buildRelatedModels($this->model);
$__backup = $this->model->hasAndBelongsToMany['TestModel7'];
@@ -1284,7 +1284,7 @@ class DboSourceTest extends UnitTestCase {
$className = $assocData['className'];
}
$model->$className = new $className();
- $model->$className->loadInfo();
+ $model->$className->schema();
}
}
}
diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php
index 262b9142c..6738b961a 100644
--- a/cake/tests/cases/libs/model/model.test.php
+++ b/cake/tests/cases/libs/model/model.test.php
@@ -45,24 +45,14 @@ class Test extends Model {
var $useTable = false;
var $name = 'Test';
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key'=>'primary'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'email', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
- array('name' => 'notes', 'type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)));
- }
-
function schema() {
- return new Set(array(
+ return array(
'id'=> array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key'=>'primary'),
'name'=> array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'email'=> array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'notes'=> array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''),
'created'=> array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- 'updated'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)));
+ 'updated'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null));
}
}
@@ -89,14 +79,15 @@ class TestValidate extends Model {
return false;
}
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'title', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'body', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'number', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'modified', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)));
+ function schema() {
+ return array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'title' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'body' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => ''),
+ 'number' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'modified' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
}
@@ -124,7 +115,7 @@ class Article extends CakeTestModel {
var $validate = array('user_id' => VALID_NUMBER, 'title' => array('allowEmpty' => false, 'rule' => VALID_NOT_EMPTY), 'body' => VALID_NOT_EMPTY);
function titleDuplicate ($title) {
- if($title === 'My Article Title') {
+ if ($title === 'My Article Title') {
return false;
}
return true;
@@ -581,10 +572,8 @@ class ModelTest extends CakeTestCase {
$result = $this->model->create();
$expected = array('Test' => array('notes' => 'write some notes here'));
$this->assertEqual($result, $expected);
-
$this->model =& new User();
- $result = $this->model->loadInfo();
- $result = $result->value;
+ $result = $this->model->schema();
$db =& ConnectionManager::getDataSource('test_suite');
if (isset($db->columns['primary_key']['length'])) {
@@ -596,17 +585,18 @@ class ModelTest extends CakeTestCase {
}
$expected = array(
- array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => null, 'length' => $intLength, 'key' => 'primary', 'extra' => 'auto_increment'),
- array('name' => 'user', 'type' => 'string', 'null' => false, 'default' => '', 'length' => 255),
- array('name' => 'password', 'type' => 'string', 'null' => false, 'default' => '', 'length' => 255),
- array('name' => 'created', 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null),
- array('name' => 'updated', 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null));
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => $intLength, 'key' => 'primary', 'extra' => 'auto_increment'),
+ 'user' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => 255),
+ 'password' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => 255),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'length' => null),
+ 'updated'=> array('type' => 'datetime', 'null' => true, 'default' => null, 'length' => null));
$this->assertEqual($result, $expected);
$this->model =& new Article();
$result = $this->model->create();
$expected = array('Article' => array('published' => 'N'));
$this->assertEqual($result, $expected);
+
}
function testCreationWithMultipleData() {
@@ -3010,8 +3000,8 @@ class ValidationTest extends CakeTestModel {
return $data === 1;
}
- function loadInfo() {
- return new Set();
+ function schema() {
+ return array();
}
}
diff --git a/cake/tests/cases/libs/sanitize.test.php b/cake/tests/cases/libs/sanitize.test.php
index 746d5137a..4fe1c5105 100644
--- a/cake/tests/cases/libs/sanitize.test.php
+++ b/cake/tests/cases/libs/sanitize.test.php
@@ -98,4 +98,4 @@ class SanitizeTest extends UnitTestCase {
$this->assertEqual($result, $expected);
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/view/helpers/ajax.test.php b/cake/tests/cases/libs/view/helpers/ajax.test.php
index 5818e6eed..d1a9d1ee8 100644
--- a/cake/tests/cases/libs/view/helpers/ajax.test.php
+++ b/cake/tests/cases/libs/view/helpers/ajax.test.php
@@ -43,12 +43,13 @@ class PostAjaxTest extends Model {
var $primaryKey = 'id';
var $useTable = false;
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)));
+ function schema() {
+ return array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
}
@@ -112,7 +113,7 @@ class AjaxTest extends UnitTestCase {
$this->assertEqual($result, $expected);
$result = $this->Ajax->dropRemote('droppable', array('accept' => 'crap'), array('url' => '/posts'));
- $expected = '';
+ $expected = '';
$this->assertEqual($result, $expected);
}
diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php
index 3a0f508f7..d13f0687d 100644
--- a/cake/tests/cases/libs/view/helpers/form.test.php
+++ b/cake/tests/cases/libs/view/helpers/form.test.php
@@ -48,13 +48,14 @@ class Contact extends CakeTestModel {
var $useTable = false;
var $name = 'Contact';
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'published', 'type' => 'date', 'null' => true, 'default' => null, 'length' => null),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)));
+ function schema() {
+ return array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'published' => array('type' => 'date', 'null' => true, 'default' => null, 'length' => null),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
}
@@ -64,13 +65,15 @@ class UserForm extends CakeTestModel {
var $name = 'UserForm';
var $hasMany = array('OpenidUrl' => array('className' => 'OpenidUrl', 'foreignKey' => 'user_form_id'));
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)));
+ function schema() {
+ return array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'published' => array('type' => 'date', 'null' => true, 'default' => null, 'length' => null),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
+
}
class OpenidUrl extends CakeTestModel {
@@ -79,11 +82,12 @@ class OpenidUrl extends CakeTestModel {
var $name = 'OpenidUrl';
var $belongsTo = array('UserForm' => array('className' => 'UserForm', 'foreignKey' => 'user_form_id'));
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'user_form_id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'url', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),));
+ function schema() {
+ return array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'user_form_id' => array('type' => 'user_form_id', 'null' => '', 'default' => '', 'length' => '8'),
+ 'url' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ );
}
function beforeValidate() {
@@ -98,13 +102,14 @@ class ValidateUser extends CakeTestModel {
var $name = 'ValidateUser';
var $hasOne = array('ValidateProfile' => array('className' => 'ValidateProfile', 'foreignKey' => 'user_id'));
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'email', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)));
+ function schema() {
+ return array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'email' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
function beforeValidate() {
@@ -120,14 +125,15 @@ class ValidateProfile extends CakeTestModel {
var $hasOne = array('ValidateItem' => array('className' => 'ValidateItem', 'foreignKey' => 'profile_id'));
var $belongsTo = array('ValidateUser' => array('className' => 'ValidateUser', 'foreignKey' => 'user_id'));
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'user_id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'full_name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'city', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)));
+ function schema() {
+ return array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'user_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'full_name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'city' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
function beforeValidate() {
@@ -143,14 +149,15 @@ class ValidateItem extends CakeTestModel {
var $name = 'ValidateItem';
var $belongsTo = array('ValidateProfile' => array('className' => 'ValidateProfile', 'foreignKey' => 'profile_id'));
- function loadInfo() {
- return new Set(array(
- array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'profile_id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'description', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)));
+ function schema() {
+ return array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'profile_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'description' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
}
function beforeValidate() {
@@ -737,7 +744,7 @@ class FormHelperTest extends CakeTestCase {
$this->assertPattern('/^]+\/>]+checked="checked"[^<>]+\/>$/', $result);
$result = $this->Form->checkbox('Model.field', array('value' => 'myvalue'));
-
+
$this->assertNoPattern('/^]+[^type|name|id|value]=[^<>]*\/>]+\/>$/', $result);
$this->assertNoPattern('/^]+\/>]+[^type|name|id|value|class|checked]=[^<>]*>$/', $result);
$this->assertPattern('/^]+id="ModelField_"[^<>]+\/>]+\/>$/', $result);
@@ -748,7 +755,7 @@ class FormHelperTest extends CakeTestCase {
$this->Form->data['Model']['field'] = '';
$result = $this->Form->checkbox('Model.field', array('id' => 'theID'));
-
+
$this->assertNoPattern('/^]+[^type|name|id|value]=[^<>]*\/>]+\/>$/', $result);
$this->assertNoPattern('/^]+\/>]+[^type|name|id|value|class|checked]=[^<>]*>$/', $result);
$this->assertPattern('/^]+id="theID_"[^<>]+\/>]+\/>$/', $result);
@@ -756,10 +763,10 @@ class FormHelperTest extends CakeTestCase {
$this->assertPattern('/^]+\/>]+id="theID"[^<>]+\/>$/', $result);
$this->assertPattern('/^]+\/>]+value="1"[^<>]+\/>$/', $result);
$this->assertNoPattern('/^]+\/>]+checked="checked"[^<>]+\/>$/', $result);
-
+
unset($this->Form->validationErrors['Model']['field']);
$result = $this->Form->checkbox('Model.field', array('value' => 'myvalue'));
-
+
$this->assertNoPattern('/^]+[^type|name|id|value]=[^<>]*\/>]+\/>$/', $result);
$this->assertNoPattern('/^]+\/>]+[^type|name|id|value|class|checked]=[^<>]*>$/', $result);
$this->assertPattern('/^]+id="ModelField_"[^<>]+\/>]+\/>$/', $result);
@@ -779,7 +786,7 @@ class FormHelperTest extends CakeTestCase {
$this->assertPattern('/^]+\/>]+id="ModelField"[^<>]+\/>$/', $result);
$this->assertPattern('/^]+\/>]+value="1"[^<>]+\/>$/', $result);
$this->assertNoPattern('/^]+\/>]+checked="checked"[^<>]+\/>$/', $result);
-
+
$result = $this->Form->checkbox('Model.field', array('checked' => false));
$this->assertNoPattern('/^]+[^type|name|id|value]=[^<>]*\/>]+\/>$/', $result);
$this->assertNoPattern('/^]+\/>]+[^type|name|id|value|class|checked]=[^<>]*>$/', $result);
@@ -788,11 +795,11 @@ class FormHelperTest extends CakeTestCase {
$this->assertPattern('/^]+\/>]+id="ModelField"[^<>]+\/>$/', $result);
$this->assertPattern('/^]+\/>]+value="1"[^<>]+\/>$/', $result);
$this->assertNoPattern('/^]+\/>]+checked="checked"[^<>]+\/>$/', $result);
-
+
$this->Form->validationErrors['Model']['field'] = 1;
$this->Form->data['Contact']['published'] = 1;
$result = $this->Form->checkbox('Contact.published', array('id'=>'theID'));
-
+
$this->assertNoPattern('/^]+[^type|name|id|value]=[^<>]*\/>]+\/>$/', $result);
$this->assertNoPattern('/^]+\/>]+[^type|name|id|value|class|checked]=[^<>]*>$/', $result);
$this->assertPattern('/^]+id="theID_"[^<>]+\/>]+\/>$/', $result);
@@ -804,7 +811,7 @@ class FormHelperTest extends CakeTestCase {
$this->Form->validationErrors['Model']['field'] = 1;
$this->Form->data['Contact']['published'] = 0;
$result = $this->Form->checkbox('Contact.published', array('id'=>'theID'));
-
+
$this->assertNoPattern('/^]+[^type|name|id|value]=[^<>]*\/>]+\/>$/', $result);
$this->assertNoPattern('/^]+\/>]+[^type|name|id|value|class|checked]=[^<>]*>$/', $result);
$this->assertPattern('/^]+id="theID_"[^<>]+\/>]+\/>$/', $result);
@@ -1189,7 +1196,7 @@ class FormHelperTest extends CakeTestCase {
function __sortFields($fields) {
foreach ($fields as $key => $value) {
- if(strpos($key, '_') !== 0) {
+ if ($key{0} !== '_') {
sort($fields[$key]);
}
}
@@ -1198,4 +1205,4 @@ class FormHelperTest extends CakeTestCase {
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php
index 210fab3cf..6f1a2b2f8 100644
--- a/cake/tests/cases/libs/view/helpers/html.test.php
+++ b/cake/tests/cases/libs/view/helpers/html.test.php
@@ -179,4 +179,4 @@ class HtmlHelperTest extends UnitTestCase {
unset($this->Html);
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/tests/lib/cake_reporter.php b/cake/tests/lib/cake_reporter.php
index ab641cc44..bd9701e48 100644
--- a/cake/tests/lib/cake_reporter.php
+++ b/cake/tests/lib/cake_reporter.php
@@ -74,4 +74,4 @@ class CakeHtmlReporter extends HtmlReporter {
print "\n";
}
}
-?>
+?>
\ No newline at end of file
diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php
index b319d33e0..cac53a295 100644
--- a/cake/tests/lib/cake_test_fixture.php
+++ b/cake/tests/lib/cake_test_fixture.php
@@ -71,8 +71,7 @@ class CakeTestFixture extends Object {
$db =& ConnectionManager::getDataSource($model->useDbConfig);
$db->cacheSources = false;
$this->table = $this->useTable;
- $schema = $model->schema(true);
- $this->fields = $schema->value;
+ $this->fields = $model->schema(true);
$this->fields[$model->primaryKey]['key'] = 'primary';
} elseif (isset($import['table'])) {
$model =& new Model(null, $import['table'], $import['connection']);
@@ -81,8 +80,7 @@ class CakeTestFixture extends Object {
$model->name = Inflector::camelize(Inflector::singularize($import['table']));
$model->table = $import['table'];
$model->tablePrefix = $db->config['prefix'];
- $schema = $model->schema(true);
- $this->fields = $schema->value;
+ $this->fields = $model->schema(true);
}
if ($import['records'] !== false && isset($model) && isset($db)) {
diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php
index 6440ef680..de1b92018 100644
--- a/cake/tests/lib/test_manager.php
+++ b/cake/tests/lib/test_manager.php
@@ -364,4 +364,4 @@ class HtmlTestManager extends TestManager {
return $buffer;
}
}
-?>
+?>
\ No newline at end of file
| |