mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding enhancement from Ticket #2366
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4823 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
cc030bed0f
commit
9a6d54b400
3 changed files with 29 additions and 5 deletions
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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++) {
|
||||
|
|
Loading…
Reference in a new issue