mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Changing Set interface to act like NeatArray, disabling Model::cacheQueries by default, and removing NeatArray usage in Model
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3888 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
403bcb54b4
commit
099144bcbd
2 changed files with 27 additions and 12 deletions
|
@ -213,7 +213,7 @@ class Model extends Overloadable {
|
|||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
var $cacheQueries = true;
|
||||
var $cacheQueries = false;
|
||||
|
||||
/**
|
||||
* belongsTo association
|
||||
|
@ -755,7 +755,7 @@ class Model extends Overloadable {
|
|||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
|
||||
if (!is_object($this->_tableInfo) && $db->isInterfaceSupported('describe')) {
|
||||
$this->_tableInfo = new NeatArray($db->describe($this));
|
||||
$this->_tableInfo = new Set($db->describe($this));
|
||||
}
|
||||
return $this->_tableInfo;
|
||||
}
|
||||
|
@ -806,9 +806,9 @@ class Model extends Overloadable {
|
|||
}
|
||||
|
||||
if ($this->_tableInfo != null) {
|
||||
return $this->_tableInfo->findIn('name', $name);
|
||||
return in_array($name, $this->_tableInfo->extract('{n}.name'));
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Initializes the model for writing a new record.
|
||||
|
@ -1203,6 +1203,16 @@ class Model extends Overloadable {
|
|||
$db->query("DELETE FROM " . $db->name($db->fullTableName($data['joinTable'])) . " WHERE " . $db->name($data['foreignKey']) . " = '{$id}'");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Allows model records to be deleted based on a set of conditions
|
||||
*
|
||||
* @param mixed $conditions
|
||||
* @param mixed $fields
|
||||
* @return boolean True on success, false on failure
|
||||
*/
|
||||
function deleteAll($conditions, $cascade = true) {
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
}
|
||||
/**
|
||||
* Returns true if a record with set id exists.
|
||||
*
|
||||
|
|
|
@ -39,7 +39,7 @@ class Set extends Object {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $__value = array();
|
||||
var $value = array();
|
||||
/**
|
||||
* Constructor. Defaults to an empty array.
|
||||
*
|
||||
|
@ -47,9 +47,9 @@ class Set extends Object {
|
|||
*/
|
||||
function __construct() {
|
||||
if (func_num_args() == 1 && is_array(func_get_arg(0))) {
|
||||
$this->__value = func_get_arg(0);
|
||||
$this->value = func_get_arg(0);
|
||||
} else {
|
||||
$this->__value = func_get_args();
|
||||
$this->value = func_get_args();
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -58,7 +58,7 @@ class Set extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function get() {
|
||||
return $this->__value;
|
||||
return $this->value;
|
||||
}
|
||||
/**
|
||||
* Merges the contents of the array object with $array
|
||||
|
@ -72,7 +72,7 @@ class Set extends Object {
|
|||
return array_merge_recursive($array, $array2);
|
||||
}
|
||||
if ($array == null) {
|
||||
$array = $this->__value;
|
||||
$array = $this->value;
|
||||
} elseif (is_object($array) && (is_a($array, 'set') || is_a($array, 'Set'))) {
|
||||
$array = $array->get();
|
||||
} elseif (is_object($array)) {
|
||||
|
@ -80,8 +80,8 @@ class Set extends Object {
|
|||
} elseif (!is_array($array)) {
|
||||
$array = array($array);
|
||||
}
|
||||
$this->__value = array_merge_recursive($this->__value, $array);
|
||||
return $this->__value;
|
||||
$this->value = array_merge_recursive($this->value, $array);
|
||||
return $this->value;
|
||||
}
|
||||
/**
|
||||
* Maps the contents of the Set object to an object hierarchy
|
||||
|
@ -173,7 +173,12 @@ class Set extends Object {
|
|||
* @param mixed $path As an array, or as a dot-separated string.
|
||||
* @return array
|
||||
*/
|
||||
function extract($data, $path) {
|
||||
function extract($data, $path = null) {
|
||||
if ($path === null && is_a($this, 'set')) {
|
||||
$path = $data;
|
||||
$data = $this->get();
|
||||
}
|
||||
|
||||
if (!is_array($path)) {
|
||||
if (strpos($path, '/') !== 0 && strpos($path, './') === false) {
|
||||
$path = explode('.', $path);
|
||||
|
|
Loading…
Reference in a new issue