From 7c9e71e72d5fae7bfc3d28eef82affefd97f44df Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 3 Mar 2007 15:18:45 +0000 Subject: [PATCH] Refactoring Model::getColumnType() and Model::getColumnTypes() git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4567 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/model.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 8b675d955..c7c2d3e71 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -830,14 +830,7 @@ class Model extends Overloadable { */ function getColumnTypes() { $columns = $this->loadInfo(); - $columns = $columns->value; - $db =& ConnectionManager::getDataSource($this->useDbConfig); - $cols = array(); - - foreach($columns as $col) { - $cols[$col['name']] = $col['type']; - } - return $cols; + return array_combine($columns->extract('{n}.name'), $columns->extract('{n}.type')); } /** * Returns the column type of a column in the model @@ -846,14 +839,9 @@ class Model extends Overloadable { * @return string Column type */ function getColumnType($column) { - $columns = $this->loadInfo(); - $columns = $columns->value; - $cols = array(); - - foreach($columns as $col) { - if ($col['name'] == $column) { - return $col['type']; - } + $cols = $this->getColumnTypes(); + if (isset($cols[$column])) { + return $cols[$column]; } return null; }