mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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
This commit is contained in:
parent
5964d074c5
commit
7c9e71e72d
1 changed files with 4 additions and 16 deletions
|
@ -830,14 +830,7 @@ class Model extends Overloadable {
|
||||||
*/
|
*/
|
||||||
function getColumnTypes() {
|
function getColumnTypes() {
|
||||||
$columns = $this->loadInfo();
|
$columns = $this->loadInfo();
|
||||||
$columns = $columns->value;
|
return array_combine($columns->extract('{n}.name'), $columns->extract('{n}.type'));
|
||||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
|
||||||
$cols = array();
|
|
||||||
|
|
||||||
foreach($columns as $col) {
|
|
||||||
$cols[$col['name']] = $col['type'];
|
|
||||||
}
|
|
||||||
return $cols;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the column type of a column in the model
|
* Returns the column type of a column in the model
|
||||||
|
@ -846,14 +839,9 @@ class Model extends Overloadable {
|
||||||
* @return string Column type
|
* @return string Column type
|
||||||
*/
|
*/
|
||||||
function getColumnType($column) {
|
function getColumnType($column) {
|
||||||
$columns = $this->loadInfo();
|
$cols = $this->getColumnTypes();
|
||||||
$columns = $columns->value;
|
if (isset($cols[$column])) {
|
||||||
$cols = array();
|
return $cols[$column];
|
||||||
|
|
||||||
foreach($columns as $col) {
|
|
||||||
if ($col['name'] == $column) {
|
|
||||||
return $col['type'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue