From 9a6d54b4000a6eacb45ee2822f3f98acea891a4a Mon Sep 17 00:00:00 2001 From: phpnut Date: Sun, 8 Apr 2007 23:30:31 +0000 Subject: [PATCH] Adding enhancement from Ticket #2366 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4823 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/datasources/datasource.php | 13 +++++++++++++ cake/libs/model/datasources/dbo_source.php | 3 +++ cake/libs/model/model.php | 18 +++++++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index c766d5385..f7c8ab599 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -84,6 +84,12 @@ class DataSource extends Object { * @access public */ var $took = null; +/** + * Enter description here... + * + * @var boolean + */ + var $cacheSources = true; /** * Enter description here... * @@ -221,6 +227,9 @@ class DataSource extends Object { * @return void */ function __cacheDescription($object, $data = null) { + if($this->cacheSources === false){ + return null; + } if (Configure::read() > 0) { $expires = "+15 seconds"; } else { @@ -273,6 +282,10 @@ class DataSource extends Object { * @return mixed */ function describe($model) { + if($this->cacheSources === false){ + return null; + } + if (isset($this->__descriptions[$model->tablePrefix.$model->table])) { return $this->__descriptions[$model->tablePrefix.$model->table]; } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index dd47591ac..c03b2259b 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -132,6 +132,9 @@ class DboSource extends DataSource { * @return array */ function listSources($data = null) { + if($this->cacheSources === false){ + return null; + } if ($this->_sources != null) { return $this->_sources; } diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index c28a69f21..15de28562 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -260,6 +260,12 @@ class Model extends Overloadable { * @var array */ var $behaviors = array(); +/** + * Enter description here... + * + * @var boolean + */ + var $cacheSources = true; /** * Mapped behavior methods @@ -731,6 +737,7 @@ class Model extends Overloadable { function setSource($tableName) { $this->setDataSource($this->useDbConfig); $db =& ConnectionManager::getDataSource($this->useDbConfig); + $db->cacheSources = $this->cacheSources; if ($db->isInterfaceSupported('listSources')) { $sources = $db->listSources(); @@ -823,6 +830,7 @@ class Model extends Overloadable { */ function loadInfo() { $db =& ConnectionManager::getDataSource($this->useDbConfig); + $db->cacheSources = $this->cacheSources; if (!is_object($this->_tableInfo) && $db->isInterfaceSupported('describe') && $this->useTable !== false) { $this->_tableInfo = new Set($db->describe($this)); @@ -1140,7 +1148,7 @@ class Model extends Overloadable { $keys[] = $this->hasAndBelongsToMany[$assoc]['associationForeignKey']; $fields[$assoc] = join(',', $keys); unset($keys); - + foreach($value as $update) { if (!empty($update)) { $values[] = $db->value($id, $this->getColumnType($this->primaryKey)); @@ -1150,7 +1158,7 @@ class Model extends Overloadable { unset ($values); } } - + if (!empty($newValues)) { $newValue[$assoc] = $newValues; unset($newValues); @@ -1160,16 +1168,16 @@ class Model extends Overloadable { } } } - + if (isset($joinTable)) { $total = count($joinTable); - + if(is_array($newValue)) { foreach ($newValue as $loopAssoc => $val) { $db =& ConnectionManager::getDataSource($this->useDbConfig); $table = $db->name($db->fullTableName($joinTable[$loopAssoc])); $db->query("DELETE FROM {$table} WHERE {$mainKey[$loopAssoc]} = '{$id}'"); - + if (!empty($newValue[$loopAssoc])) { $secondCount = count($newValue[$loopAssoc]); for($x = 0; $x < $secondCount; $x++) {