mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '2.0-models' into 2.0
This commit is contained in:
commit
2414ad8c8f
8 changed files with 431 additions and 529 deletions
|
@ -32,112 +32,6 @@ class DataSource extends Object {
|
||||||
*/
|
*/
|
||||||
public $connected = false;
|
public $connected = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Print full query debug info?
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $fullDebug = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Error description of last query
|
|
||||||
*
|
|
||||||
* @var unknown_type
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $error = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* String to hold how many rows were affected by the last SQL operation.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $affected = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Number of rows in current resultset
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $numRows = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Time the last query took
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $took = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The starting character that this DataSource uses for quoted identifiers.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $startQuote = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ending character that this DataSource uses for quoted identifiers.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $endQuote = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Result
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
protected $_result = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Queries count.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
protected $_queriesCnt = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Total duration of all queries.
|
|
||||||
*
|
|
||||||
* @var unknown_type
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
protected $_queriesTime = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log of queries executed by this DataSource
|
|
||||||
*
|
|
||||||
* @var unknown_type
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
protected $_queriesLog = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Maximum number of items in query log
|
|
||||||
*
|
|
||||||
* This is to prevent query log taking over too much memory.
|
|
||||||
*
|
|
||||||
* @var int Maximum number of queries in the queries log.
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
protected $_queriesLogMax = 200;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Caches serialzed results of executed queries
|
|
||||||
*
|
|
||||||
* @var array Maximum number of queries in the queries log.
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
protected $_queryCache = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default configuration of a specific DataSource
|
* The default configuration of a specific DataSource
|
||||||
*
|
*
|
||||||
|
@ -162,14 +56,6 @@ class DataSource extends Object {
|
||||||
*/
|
*/
|
||||||
protected $_sources = null;
|
protected $_sources = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* A reference to the physical connection of this DataSource
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $connection = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DataSource configuration
|
* The DataSource configuration
|
||||||
*
|
*
|
||||||
|
@ -178,14 +64,6 @@ class DataSource extends Object {
|
||||||
*/
|
*/
|
||||||
public $config = array();
|
public $config = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* The DataSource configuration key name
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $configKeyName = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not this DataSource is in the middle of a transaction
|
* Whether or not this DataSource is in the middle of a transaction
|
||||||
*
|
*
|
||||||
|
@ -238,21 +116,7 @@ class DataSource extends Object {
|
||||||
Cache::write($key, $data, '_cake_model_');
|
Cache::write($key, $data, '_cake_model_');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_sources = $sources;
|
return $this->_sources = $sources;
|
||||||
return $sources;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience method for DboSource::listSources(). Returns source names in lowercase.
|
|
||||||
*
|
|
||||||
* @param boolean $reset Whether or not the source list should be reset.
|
|
||||||
* @return array Array of sources available in this datasource
|
|
||||||
*/
|
|
||||||
public function sources($reset = false) {
|
|
||||||
if ($reset === true) {
|
|
||||||
$this->_sources = null;
|
|
||||||
}
|
|
||||||
return array_map('strtolower', $this->listSources());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,7 +125,7 @@ class DataSource extends Object {
|
||||||
* @param Model $model
|
* @param Model $model
|
||||||
* @return array Array of Metadata for the $model
|
* @return array Array of Metadata for the $model
|
||||||
*/
|
*/
|
||||||
public function describe($model) {
|
public function describe(Model $model) {
|
||||||
if ($this->cacheSources === false) {
|
if ($this->cacheSources === false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -326,7 +190,7 @@ class DataSource extends Object {
|
||||||
* @param array $values An Array of values to save.
|
* @param array $values An Array of values to save.
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
public function create($model, $fields = null, $values = null) {
|
public function create(Model $model, $fields = null, $values = null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +203,7 @@ class DataSource extends Object {
|
||||||
* @param array $queryData An array of query data used to find the data you want
|
* @param array $queryData An array of query data used to find the data you want
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function read($model, $queryData = array()) {
|
public function read(Model $model, $queryData = array()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +217,7 @@ class DataSource extends Object {
|
||||||
* @param array $values Array of values to be update $fields to.
|
* @param array $values Array of values to be update $fields to.
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function update($model, $fields = null, $values = null) {
|
public function update(Model $model, $fields = null, $values = null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +229,7 @@ class DataSource extends Object {
|
||||||
* @param Model $model The model class having record(s) deleted
|
* @param Model $model The model class having record(s) deleted
|
||||||
* @param mixed $id Primary key of the model
|
* @param mixed $id Primary key of the model
|
||||||
*/
|
*/
|
||||||
public function delete($model, $id = null) {
|
public function delete(Model $model, $id = null) {
|
||||||
if ($id == null) {
|
if ($id == null) {
|
||||||
$id = $model->id;
|
$id = $model->id;
|
||||||
}
|
}
|
||||||
|
@ -412,20 +276,6 @@ class DataSource extends Object {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the DataSource supports the given interface (method)
|
|
||||||
*
|
|
||||||
* @param string $interface The name of the interface (method)
|
|
||||||
* @return boolean True on success
|
|
||||||
*/
|
|
||||||
public function isInterfaceSupported($interface) {
|
|
||||||
static $methods = false;
|
|
||||||
if ($methods === false) {
|
|
||||||
$methods = array_map('strtolower', get_class_methods($this));
|
|
||||||
}
|
|
||||||
return in_array(strtolower($interface), $methods);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the configuration for the DataSource.
|
* Sets the configuration for the DataSource.
|
||||||
* Merges the $config information with the _baseConfig and the existing $config property.
|
* Merges the $config information with the _baseConfig and the existing $config property.
|
||||||
|
@ -479,7 +329,7 @@ class DataSource extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
* @todo Remove and refactor $assocData, ensure uses of the method have the param removed too.
|
* @todo Remove and refactor $assocData, ensure uses of the method have the param removed too.
|
||||||
*/
|
*/
|
||||||
function insertQueryData($query, $data, $association, $assocData, &$model, &$linkModel, $stack) {
|
function insertQueryData($query, $data, $association, $assocData, Model $model, Model $linkModel, $stack) {
|
||||||
$keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}');
|
$keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}');
|
||||||
|
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
|
@ -559,7 +409,7 @@ class DataSource extends Object {
|
||||||
* @param string $key Key name to make
|
* @param string $key Key name to make
|
||||||
* @return string Key name for model.
|
* @return string Key name for model.
|
||||||
*/
|
*/
|
||||||
public function resolveKey($model, $key) {
|
public function resolveKey(Model $model, $key) {
|
||||||
return $model->alias . $key;
|
return $model->alias . $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,8 +420,7 @@ class DataSource extends Object {
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
if ($this->_transactionStarted) {
|
if ($this->_transactionStarted) {
|
||||||
$null = null;
|
$this->rollback();
|
||||||
$this->rollback($null);
|
|
||||||
}
|
}
|
||||||
if ($this->connected) {
|
if ($this->connected) {
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
|
@ -209,21 +209,19 @@ class DboMysql extends DboSource {
|
||||||
$this->map = array();
|
$this->map = array();
|
||||||
$numFields = $results->columnCount();
|
$numFields = $results->columnCount();
|
||||||
$index = 0;
|
$index = 0;
|
||||||
$j = 0;
|
|
||||||
|
|
||||||
while ($j < $numFields) {
|
while ($numFields-- > 0) {
|
||||||
$column = $results->getColumnMeta($j);
|
$column = $results->getColumnMeta($index);
|
||||||
if (!empty($column['native_type'])) {
|
if (empty($column['native_type'])) {
|
||||||
$type = $column['native_type'];
|
|
||||||
} else {
|
|
||||||
$type = ($column['len'] == 1) ? 'boolean' : 'string';
|
$type = ($column['len'] == 1) ? 'boolean' : 'string';
|
||||||
|
} else {
|
||||||
|
$type = $column['native_type'];
|
||||||
}
|
}
|
||||||
if (!empty($column['table']) && strpos($column['name'], $this->virtualFieldSeparator) === false) {
|
if (!empty($column['table']) && strpos($column['name'], $this->virtualFieldSeparator) === false) {
|
||||||
$this->map[$index++] = array($column['table'], $column['name'], $type);
|
$this->map[$index++] = array($column['table'], $column['name'], $type);
|
||||||
} else {
|
} else {
|
||||||
$this->map[$index++] = array(0, $column['name'], $type);
|
$this->map[$index++] = array(0, $column['name'], $type);
|
||||||
}
|
}
|
||||||
$j++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,15 +236,14 @@ class DboMysql extends DboSource {
|
||||||
foreach ($this->map as $col => $meta) {
|
foreach ($this->map as $col => $meta) {
|
||||||
list($table, $column, $type) = $meta;
|
list($table, $column, $type) = $meta;
|
||||||
$resultRow[$table][$column] = $row[$col];
|
$resultRow[$table][$column] = $row[$col];
|
||||||
if ($type == 'boolean' && !is_null($row[$col])) {
|
if ($type === 'boolean' && !is_null($row[$col])) {
|
||||||
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
|
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $resultRow;
|
return $resultRow;
|
||||||
} else {
|
|
||||||
$this->_result->closeCursor();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
$this->_result->closeCursor();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -305,7 +302,7 @@ class DboMysql extends DboSource {
|
||||||
foreach ($cols as $column) {
|
foreach ($cols as $column) {
|
||||||
$fields[$column->Field] = array(
|
$fields[$column->Field] = array(
|
||||||
'type' => $this->column($column->Type),
|
'type' => $this->column($column->Type),
|
||||||
'null' => ($column->Null == 'YES' ? true : false),
|
'null' => ($column->Null === 'YES' ? true : false),
|
||||||
'default' => $column->Default,
|
'default' => $column->Default,
|
||||||
'length' => $this->length($column->Type),
|
'length' => $this->length($column->Type),
|
||||||
);
|
);
|
||||||
|
@ -410,7 +407,7 @@ class DboMysql extends DboSource {
|
||||||
* @param string $enc Database encoding
|
* @param string $enc Database encoding
|
||||||
*/
|
*/
|
||||||
function setEncoding($enc) {
|
function setEncoding($enc) {
|
||||||
return $this->_execute('SET NAMES ' . $enc) != false;
|
return $this->_execute('SET NAMES ' . $enc) !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -500,7 +497,7 @@ class DboMysql extends DboSource {
|
||||||
}
|
}
|
||||||
$colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes));
|
$colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes));
|
||||||
$colList = array_merge($colList, $this->_alterTableParameters($curTable, $tableParameters));
|
$colList = array_merge($colList, $this->_alterTableParameters($curTable, $tableParameters));
|
||||||
$out .= "\t" . join(",\n\t", $colList) . ";\n\n";
|
$out .= "\t" . implode(",\n\t", $colList) . ";\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
|
@ -517,7 +514,7 @@ class DboMysql extends DboSource {
|
||||||
function dropSchema(CakeSchema $schema, $table = null) {
|
function dropSchema(CakeSchema $schema, $table = null) {
|
||||||
$out = '';
|
$out = '';
|
||||||
foreach ($schema->tables as $curTable => $columns) {
|
foreach ($schema->tables as $curTable => $columns) {
|
||||||
if (!$table || $table == $curTable) {
|
if (!$table || $table === $curTable) {
|
||||||
$out .= 'DROP TABLE IF EXISTS ' . $this->fullTableName($curTable) . ";\n";
|
$out .= 'DROP TABLE IF EXISTS ' . $this->fullTableName($curTable) . ";\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -584,7 +581,7 @@ class DboMysql extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns an detailed array of sources (tables) in the database.
|
* Returns an detailed array of sources (tables) in the database.
|
||||||
*
|
*
|
||||||
* @param string $name Table name to get parameters
|
* @param string $name Table name to get parameters
|
||||||
* @return array Array of tablenames in the database
|
* @return array Array of tablenames in the database
|
||||||
*/
|
*/
|
||||||
function listDetailedSources($name = null) {
|
function listDetailedSources($name = null) {
|
||||||
|
@ -629,7 +626,7 @@ class DboMysql extends DboSource {
|
||||||
if (is_array($real)) {
|
if (is_array($real)) {
|
||||||
$col = $real['name'];
|
$col = $real['name'];
|
||||||
if (isset($real['limit'])) {
|
if (isset($real['limit'])) {
|
||||||
$col .= '('.$real['limit'].')';
|
$col .= '(' . $real['limit'] . ')';
|
||||||
}
|
}
|
||||||
return $col;
|
return $col;
|
||||||
}
|
}
|
||||||
|
@ -643,19 +640,19 @@ class DboMysql extends DboSource {
|
||||||
if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
|
if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
|
||||||
return $col;
|
return $col;
|
||||||
}
|
}
|
||||||
if (($col == 'tinyint' && $limit == 1) || $col == 'boolean') {
|
if (($col === 'tinyint' && $limit == 1) || $col === 'boolean') {
|
||||||
return 'boolean';
|
return 'boolean';
|
||||||
}
|
}
|
||||||
if (strpos($col, 'int') !== false) {
|
if (strpos($col, 'int') !== false) {
|
||||||
return 'integer';
|
return 'integer';
|
||||||
}
|
}
|
||||||
if (strpos($col, 'char') !== false || $col == 'tinytext') {
|
if (strpos($col, 'char') !== false || $col === 'tinytext') {
|
||||||
return 'string';
|
return 'string';
|
||||||
}
|
}
|
||||||
if (strpos($col, 'text') !== false) {
|
if (strpos($col, 'text') !== false) {
|
||||||
return 'text';
|
return 'text';
|
||||||
}
|
}
|
||||||
if (strpos($col, 'blob') !== false || $col == 'binary') {
|
if (strpos($col, 'blob') !== false || $col === 'binary') {
|
||||||
return 'binary';
|
return 'binary';
|
||||||
}
|
}
|
||||||
if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) {
|
if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -798,7 +798,7 @@ class Model extends Object {
|
||||||
$db = ConnectionManager::getDataSource($this->useDbConfig);
|
$db = ConnectionManager::getDataSource($this->useDbConfig);
|
||||||
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
|
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
|
||||||
|
|
||||||
if ($db->isInterfaceSupported('listSources')) {
|
if (method_exists($db, 'listSources')) {
|
||||||
$sources = $db->listSources();
|
$sources = $db->listSources();
|
||||||
if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) {
|
if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) {
|
||||||
throw new MissingTableException(array(
|
throw new MissingTableException(array(
|
||||||
|
@ -981,7 +981,7 @@ class Model extends Object {
|
||||||
if (!is_array($this->_schema) || $field === true) {
|
if (!is_array($this->_schema) || $field === true) {
|
||||||
$db = $this->getDataSource();
|
$db = $this->getDataSource();
|
||||||
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
|
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
|
||||||
if ($db->isInterfaceSupported('describe') && $this->useTable !== false) {
|
if (method_exists($db, 'describe') && $this->useTable !== false) {
|
||||||
$this->_schema = $db->describe($this, $field);
|
$this->_schema = $db->describe($this, $field);
|
||||||
} elseif ($this->useTable === false) {
|
} elseif ($this->useTable === false) {
|
||||||
$this->_schema = array();
|
$this->_schema = array();
|
||||||
|
@ -2073,7 +2073,7 @@ class Model extends Object {
|
||||||
/**
|
/**
|
||||||
* Queries the datasource and returns a result set array.
|
* Queries the datasource and returns a result set array.
|
||||||
*
|
*
|
||||||
* Also used to perform new-notation finds, where the first argument is type of find operation to perform
|
* Also used to perform notation finds, where the first argument is type of find operation to perform
|
||||||
* (all / first / count / neighbors / list / threaded ),
|
* (all / first / count / neighbors / list / threaded ),
|
||||||
* second parameter options for finding ( indexed array, including: 'conditions', 'limit',
|
* second parameter options for finding ( indexed array, including: 'conditions', 'limit',
|
||||||
* 'recursive', 'page', 'fields', 'offset', 'order')
|
* 'recursive', 'page', 'fields', 'offset', 'order')
|
||||||
|
@ -2109,43 +2109,31 @@ class Model extends Object {
|
||||||
*
|
*
|
||||||
* Behaviors and find types can also define custom finder keys which are passed into find().
|
* Behaviors and find types can also define custom finder keys which are passed into find().
|
||||||
*
|
*
|
||||||
* Specifying 'fields' for new-notation 'list':
|
* Specifying 'fields' for notation 'list':
|
||||||
*
|
*
|
||||||
* - If no fields are specified, then 'id' is used for key and 'model->displayField' is used for value.
|
* - If no fields are specified, then 'id' is used for key and 'model->displayField' is used for value.
|
||||||
* - If a single field is specified, 'id' is used for key and specified field is used for value.
|
* - If a single field is specified, 'id' is used for key and specified field is used for value.
|
||||||
* - If three fields are specified, they are used (in order) for key, value and group.
|
* - If three fields are specified, they are used (in order) for key, value and group.
|
||||||
* - Otherwise, first and second fields are used for key and value.
|
* - Otherwise, first and second fields are used for key and value.
|
||||||
*
|
*
|
||||||
* @param array $conditions SQL conditions array, or type of find operation (all / first / count /
|
* @param string $type Type of find operation (all / first / count / neighbors / list / threaded)
|
||||||
* neighbors / list / threaded)
|
* @param array $query Option fields (conditions / fields / joins / limit / offset / order / page / group / callbacks)
|
||||||
* @param mixed $fields Either a single string of a field name, or an array of field names, or
|
|
||||||
* options for matching
|
|
||||||
* @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
|
|
||||||
* @param integer $recursive The number of levels deep to fetch associated records
|
|
||||||
* @return array Array of records
|
* @return array Array of records
|
||||||
* @access public
|
|
||||||
* @link http://book.cakephp.org/view/1018/find
|
* @link http://book.cakephp.org/view/1018/find
|
||||||
*/
|
*/
|
||||||
function find($conditions = null, $fields = array(), $order = null, $recursive = null) {
|
public function find($type = 'first', $query = array()) {
|
||||||
if (!is_string($conditions) || (is_string($conditions) && !array_key_exists($conditions, $this->_findMethods))) {
|
|
||||||
$type = 'first';
|
|
||||||
$query = array_merge(compact('conditions', 'fields', 'order', 'recursive'), array('limit' => 1));
|
|
||||||
} else {
|
|
||||||
list($type, $query) = array($conditions, $fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->findQueryType = $type;
|
$this->findQueryType = $type;
|
||||||
$this->id = $this->getID();
|
$this->id = $this->getID();
|
||||||
|
|
||||||
$query = array_merge(
|
$query = array_merge(
|
||||||
array(
|
array(
|
||||||
'conditions' => null, 'fields' => null, 'joins' => array(), 'limit' => null,
|
'conditions' => null, 'fields' => null, 'joins' => array(), 'limit' => null,
|
||||||
'offset' => null, 'order' => null, 'page' => null, 'group' => null, 'callbacks' => true
|
'offset' => null, 'order' => null, 'page' => 1, 'group' => null, 'callbacks' => true
|
||||||
),
|
),
|
||||||
(array)$query
|
(array)$query
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($type != 'all') {
|
if ($type !== 'all') {
|
||||||
if ($this->_findMethods[$type] === true) {
|
if ($this->_findMethods[$type] === true) {
|
||||||
$query = $this->{'_find' . ucfirst($type)}('before', $query);
|
$query = $this->{'_find' . ucfirst($type)}('before', $query);
|
||||||
}
|
}
|
||||||
|
@ -2183,15 +2171,11 @@ class Model extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$db = $this->getDataSource()) {
|
$results = $this->getDataSource()->read($this, $query);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$results = $db->read($this, $query);
|
|
||||||
$this->resetAssociations();
|
$this->resetAssociations();
|
||||||
|
|
||||||
if ($query['callbacks'] === true || $query['callbacks'] === 'after') {
|
if ($query['callbacks'] === true || $query['callbacks'] === 'after') {
|
||||||
$results = $this->__filterResults($results);
|
$results = $this->_filterResults($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->findQueryType = null;
|
$this->findQueryType = null;
|
||||||
|
@ -2212,14 +2196,13 @@ class Model extends Object {
|
||||||
* @param array $query
|
* @param array $query
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return array
|
* @return array
|
||||||
* @access protected
|
|
||||||
* @see Model::find()
|
* @see Model::find()
|
||||||
*/
|
*/
|
||||||
function _findFirst($state, $query, $results = array()) {
|
protected function _findFirst($state, $query, $results = array()) {
|
||||||
if ($state == 'before') {
|
if ($state === 'before') {
|
||||||
$query['limit'] = 1;
|
$query['limit'] = 1;
|
||||||
return $query;
|
return $query;
|
||||||
} elseif ($state == 'after') {
|
} elseif ($state === 'after') {
|
||||||
if (empty($results[0])) {
|
if (empty($results[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2234,11 +2217,10 @@ class Model extends Object {
|
||||||
* @param array $query
|
* @param array $query
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return int The number of records found, or false
|
* @return int The number of records found, or false
|
||||||
* @access protected
|
|
||||||
* @see Model::find()
|
* @see Model::find()
|
||||||
*/
|
*/
|
||||||
function _findCount($state, $query, $results = array()) {
|
protected function _findCount($state, $query, $results = array()) {
|
||||||
if ($state == 'before') {
|
if ($state === 'before') {
|
||||||
$db = $this->getDataSource();
|
$db = $this->getDataSource();
|
||||||
if (empty($query['fields'])) {
|
if (empty($query['fields'])) {
|
||||||
$query['fields'] = $db->calculate($this, 'count');
|
$query['fields'] = $db->calculate($this, 'count');
|
||||||
|
@ -2249,7 +2231,7 @@ class Model extends Object {
|
||||||
}
|
}
|
||||||
$query['order'] = false;
|
$query['order'] = false;
|
||||||
return $query;
|
return $query;
|
||||||
} elseif ($state == 'after') {
|
} elseif ($state === 'after') {
|
||||||
if (isset($results[0][0]['count'])) {
|
if (isset($results[0][0]['count'])) {
|
||||||
return intval($results[0][0]['count']);
|
return intval($results[0][0]['count']);
|
||||||
} elseif (isset($results[0][$this->alias]['count'])) {
|
} elseif (isset($results[0][$this->alias]['count'])) {
|
||||||
|
@ -2266,11 +2248,10 @@ class Model extends Object {
|
||||||
* @param array $query
|
* @param array $query
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return array Key/value pairs of primary keys/display field values of all records found
|
* @return array Key/value pairs of primary keys/display field values of all records found
|
||||||
* @access protected
|
|
||||||
* @see Model::find()
|
* @see Model::find()
|
||||||
*/
|
*/
|
||||||
function _findList($state, $query, $results = array()) {
|
protected function _findList($state, $query, $results = array()) {
|
||||||
if ($state == 'before') {
|
if ($state === 'before') {
|
||||||
if (empty($query['fields'])) {
|
if (empty($query['fields'])) {
|
||||||
$query['fields'] = array("{$this->alias}.{$this->primaryKey}", "{$this->alias}.{$this->displayField}");
|
$query['fields'] = array("{$this->alias}.{$this->primaryKey}", "{$this->alias}.{$this->displayField}");
|
||||||
$list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null);
|
$list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null);
|
||||||
|
@ -2279,14 +2260,14 @@ class Model extends Object {
|
||||||
$query['fields'] = String::tokenize($query['fields']);
|
$query['fields'] = String::tokenize($query['fields']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($query['fields']) == 1) {
|
if (count($query['fields']) === 1) {
|
||||||
if (strpos($query['fields'][0], '.') === false) {
|
if (strpos($query['fields'][0], '.') === false) {
|
||||||
$query['fields'][0] = $this->alias . '.' . $query['fields'][0];
|
$query['fields'][0] = $this->alias . '.' . $query['fields'][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = array("{n}.{$this->alias}.{$this->primaryKey}", '{n}.' . $query['fields'][0], null);
|
$list = array("{n}.{$this->alias}.{$this->primaryKey}", '{n}.' . $query['fields'][0], null);
|
||||||
$query['fields'] = array("{$this->alias}.{$this->primaryKey}", $query['fields'][0]);
|
$query['fields'] = array("{$this->alias}.{$this->primaryKey}", $query['fields'][0]);
|
||||||
} elseif (count($query['fields']) == 3) {
|
} elseif (count($query['fields']) === 3) {
|
||||||
for ($i = 0; $i < 3; $i++) {
|
for ($i = 0; $i < 3; $i++) {
|
||||||
if (strpos($query['fields'][$i], '.') === false) {
|
if (strpos($query['fields'][$i], '.') === false) {
|
||||||
$query['fields'][$i] = $this->alias . '.' . $query['fields'][$i];
|
$query['fields'][$i] = $this->alias . '.' . $query['fields'][$i];
|
||||||
|
@ -2309,7 +2290,7 @@ class Model extends Object {
|
||||||
}
|
}
|
||||||
list($query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']) = $list;
|
list($query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']) = $list;
|
||||||
return $query;
|
return $query;
|
||||||
} elseif ($state == 'after') {
|
} elseif ($state === 'after') {
|
||||||
if (empty($results)) {
|
if (empty($results)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -2328,7 +2309,7 @@ class Model extends Object {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function _findNeighbors($state, $query, $results = array()) {
|
protected function _findNeighbors($state, $query, $results = array()) {
|
||||||
if ($state == 'before') {
|
if ($state === 'before') {
|
||||||
extract($query);
|
extract($query);
|
||||||
$conditions = (array)$conditions;
|
$conditions = (array)$conditions;
|
||||||
if (isset($field) && isset($value)) {
|
if (isset($field) && isset($value)) {
|
||||||
|
@ -2345,7 +2326,7 @@ class Model extends Object {
|
||||||
$query['field'] = $field;
|
$query['field'] = $field;
|
||||||
$query['value'] = $value;
|
$query['value'] = $value;
|
||||||
return $query;
|
return $query;
|
||||||
} elseif ($state == 'after') {
|
} elseif ($state === 'after') {
|
||||||
extract($query);
|
extract($query);
|
||||||
unset($query['conditions'][$field . ' <']);
|
unset($query['conditions'][$field . ' <']);
|
||||||
$return = array();
|
$return = array();
|
||||||
|
@ -2364,9 +2345,9 @@ class Model extends Object {
|
||||||
if (!array_key_exists('prev', $return)) {
|
if (!array_key_exists('prev', $return)) {
|
||||||
$return['prev'] = $return2[0];
|
$return['prev'] = $return2[0];
|
||||||
}
|
}
|
||||||
if (count($return2) == 2) {
|
if (count($return2) === 2) {
|
||||||
$return['next'] = $return2[1];
|
$return['next'] = $return2[1];
|
||||||
} elseif (count($return2) == 1 && !$return['prev']) {
|
} elseif (count($return2) === 1 && !$return['prev']) {
|
||||||
$return['next'] = $return2[0];
|
$return['next'] = $return2[0];
|
||||||
} else {
|
} else {
|
||||||
$return['next'] = null;
|
$return['next'] = null;
|
||||||
|
@ -2385,9 +2366,9 @@ class Model extends Object {
|
||||||
* @return array Threaded results
|
* @return array Threaded results
|
||||||
*/
|
*/
|
||||||
protected function _findThreaded($state, $query, $results = array()) {
|
protected function _findThreaded($state, $query, $results = array()) {
|
||||||
if ($state == 'before') {
|
if ($state === 'before') {
|
||||||
return $query;
|
return $query;
|
||||||
} elseif ($state == 'after') {
|
} elseif ($state === 'after') {
|
||||||
$return = $idMap = array();
|
$return = $idMap = array();
|
||||||
$ids = Set::extract($results, '{n}.' . $this->alias . '.' . $this->primaryKey);
|
$ids = Set::extract($results, '{n}.' . $this->alias . '.' . $this->primaryKey);
|
||||||
|
|
||||||
|
@ -2427,9 +2408,8 @@ class Model extends Object {
|
||||||
* @param array Results to filter
|
* @param array Results to filter
|
||||||
* @param boolean $primary If this is the primary model results (results from model where the find operation was performed)
|
* @param boolean $primary If this is the primary model results (results from model where the find operation was performed)
|
||||||
* @return array Set of filtered results
|
* @return array Set of filtered results
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __filterResults($results, $primary = true) {
|
protected function _filterResults($results, $primary = true) {
|
||||||
$return = $this->Behaviors->trigger(
|
$return = $this->Behaviors->trigger(
|
||||||
'afterFind',
|
'afterFind',
|
||||||
array(&$this, $results, $primary),
|
array(&$this, $results, $primary),
|
||||||
|
|
|
@ -26,7 +26,7 @@ if ($noLogs):
|
||||||
$logs = array();
|
$logs = array();
|
||||||
foreach ($sources as $source):
|
foreach ($sources as $source):
|
||||||
$db =& ConnectionManager::getDataSource($source);
|
$db =& ConnectionManager::getDataSource($source);
|
||||||
if (!$db->isInterfaceSupported('getLog')):
|
if (!method_exists($db, 'getLog')):
|
||||||
continue;
|
continue;
|
||||||
endif;
|
endif;
|
||||||
$logs[$source] = $db->getLog();
|
$logs[$source] = $db->getLog();
|
||||||
|
|
|
@ -288,7 +288,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null)));
|
$this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null)));
|
||||||
$result = $this->Tree->find(null, array('name', $parentField), $modelClass . '.' . $leftField . ' desc');
|
$result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc'));
|
||||||
$expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null));
|
$expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data= $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
|
|
||||||
$this->Tree->create();
|
$this->Tree->create();
|
||||||
|
@ -367,7 +367,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null));
|
$this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null));
|
||||||
$result = $this->Tree->find(null, array('name', $parentField), $modelClass . '.' . $leftField . ' desc');
|
$result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc'));
|
||||||
$expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null));
|
$expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
@ -387,10 +387,10 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parent_id = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id= $data[$modelClass]['id'];
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parent_id);
|
||||||
$direct = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField));
|
$direct = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField));
|
||||||
|
@ -414,10 +414,10 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parent_id = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->whitelist = array($parentField, 'name', 'description');
|
$this->Tree->whitelist = array($parentField, 'name', 'description');
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parent_id);
|
||||||
|
@ -461,10 +461,10 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find(array($modelClass . '.name' => '1.1'));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parent_id = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data= $this->Tree->find(array($modelClass . '.name' => '1.2'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parent_id);
|
||||||
|
|
||||||
|
@ -490,10 +490,10 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find(array($modelClass . '.name' => '1.2'));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parent_id = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data= $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
|
$data= $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parent_id);
|
||||||
|
|
||||||
|
@ -519,10 +519,10 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parent_id = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
|
|
||||||
$expects = $this->Tree->find('all');
|
$expects = $this->Tree->find('all');
|
||||||
$before = $this->Tree->read(null, $data[$modelClass]['id']);
|
$before = $this->Tree->read(null, $data[$modelClass]['id']);
|
||||||
|
@ -606,7 +606,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.2'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2')));
|
||||||
$this->Tree->moveUp($data[$modelClass]['id']);
|
$this->Tree->moveUp($data[$modelClass]['id']);
|
||||||
|
|
||||||
$parent = $this->Tree->findByName('1. Root', array('id'));
|
$parent = $this->Tree->findByName('1. Root', array('id'));
|
||||||
|
@ -628,7 +628,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.1'));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
|
|
||||||
$this->Tree->moveUp($data[$modelClass]['id']);
|
$this->Tree->moveUp($data[$modelClass]['id']);
|
||||||
|
|
||||||
|
@ -651,7 +651,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
$this->Tree->moveUp($data[$modelClass]['id'], 2);
|
$this->Tree->moveUp($data[$modelClass]['id'], 2);
|
||||||
|
|
||||||
$parent = $this->Tree->findByName('1. Root', array('id'));
|
$parent = $this->Tree->findByName('1. Root', array('id'));
|
||||||
|
@ -682,7 +682,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
$this->Tree->moveUp($data[$modelClass]['id'], true);
|
$this->Tree->moveUp($data[$modelClass]['id'], true);
|
||||||
|
|
||||||
$parent = $this->Tree->findByName('1. Root', array('id'));
|
$parent = $this->Tree->findByName('1. Root', array('id'));
|
||||||
|
@ -713,7 +713,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
$this->Tree->moveDown($data[$modelClass]['id']);
|
$this->Tree->moveDown($data[$modelClass]['id']);
|
||||||
|
|
||||||
$parent = $this->Tree->findByName('1. Root', array('id'));
|
$parent = $this->Tree->findByName('1. Root', array('id'));
|
||||||
|
@ -735,7 +735,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.2'));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
|
||||||
$this->Tree->moveDown($data[$modelClass]['id']);
|
$this->Tree->moveDown($data[$modelClass]['id']);
|
||||||
|
|
||||||
$parent = $this->Tree->findByName('1. Root', array('id'));
|
$parent = $this->Tree->findByName('1. Root', array('id'));
|
||||||
|
@ -757,7 +757,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
$this->Tree->moveDown($data[$modelClass]['id'], true);
|
$this->Tree->moveDown($data[$modelClass]['id'], true);
|
||||||
|
|
||||||
$parent = $this->Tree->findByName('1. Root', array('id'));
|
$parent = $this->Tree->findByName('1. Root', array('id'));
|
||||||
|
@ -788,7 +788,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
$this->Tree->moveDown($data[$modelClass]['id'], 2);
|
$this->Tree->moveDown($data[$modelClass]['id'], 2);
|
||||||
|
|
||||||
$parent = $this->Tree->findByName('1. Root', array('id'));
|
$parent = $this->Tree->findByName('1. Root', array('id'));
|
||||||
|
@ -819,7 +819,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->saveField('name', 'renamed');
|
$this->Tree->saveField('name', 'renamed');
|
||||||
$parent = $this->Tree->findByName('1. Root', array('id'));
|
$parent = $this->Tree->findByName('1. Root', array('id'));
|
||||||
|
@ -849,7 +849,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(1, 1);
|
$this->Tree->initialize(1, 1);
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->save(array($parentField => null));
|
$this->Tree->save(array($parentField => null));
|
||||||
|
|
||||||
|
@ -1077,7 +1077,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id= $data[$modelClass]['id'];
|
||||||
|
|
||||||
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
|
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
|
||||||
|
@ -1108,7 +1108,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
|
|
||||||
$direct = $this->Tree->childCount(null, true);
|
$direct = $this->Tree->childCount(null, true);
|
||||||
|
@ -1129,7 +1129,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.2.2'));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id= $data[$modelClass]['id'];
|
||||||
|
|
||||||
$result = $this->Tree->getParentNode(null, array('name'));
|
$result = $this->Tree->getParentNode(null, array('name'));
|
||||||
|
@ -1148,7 +1148,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.2.2'));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id= $data[$modelClass]['id'];
|
||||||
|
|
||||||
$result = $this->Tree->getPath(null, array('name'));
|
$result = $this->Tree->getPath(null, array('name'));
|
||||||
|
@ -1171,7 +1171,7 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id= $data[$modelClass]['id'];
|
||||||
|
|
||||||
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
|
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
|
||||||
|
@ -1203,13 +1203,13 @@ class NumberTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(3, 3);
|
$this->Tree->initialize(3, 3);
|
||||||
$nodes = $this->Tree->find('list', array('order' => $leftField));
|
$nodes = $this->Tree->find('list', array('order' => $leftField));
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
$this->Tree->moveDown($data[$modelClass]['id']);
|
$this->Tree->moveDown($data[$modelClass]['id']);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.2.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2.1')));
|
||||||
$this->Tree->moveDown($data[$modelClass]['id']);
|
$this->Tree->moveDown($data[$modelClass]['id']);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.3.2.2'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.3.2.2')));
|
||||||
$this->Tree->moveDown($data[$modelClass]['id']);
|
$this->Tree->moveDown($data[$modelClass]['id']);
|
||||||
|
|
||||||
$unsortedNodes = $this->Tree->find('list', array('order' => $leftField));
|
$unsortedNodes = $this->Tree->find('list', array('order' => $leftField));
|
||||||
|
@ -1676,10 +1676,10 @@ class UuidTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parent_id = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
$this->Tree->id= $data[$modelClass]['id'];
|
$this->Tree->id= $data[$modelClass]['id'];
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parent_id);
|
||||||
$direct = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField));
|
$direct = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField));
|
||||||
|
@ -1702,10 +1702,10 @@ class UuidTreeTest extends CakeTestCase {
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$parent_id = $parent[$modelClass]['id'];
|
$parent_id = $parent[$modelClass]['id'];
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
$this->Tree->whitelist = array($parentField, 'name', 'description');
|
$this->Tree->whitelist = array($parentField, 'name', 'description');
|
||||||
$this->Tree->saveField($parentField, $parent_id);
|
$this->Tree->saveField($parentField, $parent_id);
|
||||||
|
@ -1794,7 +1794,7 @@ class UuidTreeTest extends CakeTestCase {
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
|
|
||||||
$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
|
$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
|
||||||
|
@ -1825,7 +1825,7 @@ class UuidTreeTest extends CakeTestCase {
|
||||||
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
||||||
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
||||||
|
|
||||||
$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
|
|
||||||
$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
|
$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
|
||||||
|
|
|
@ -5087,7 +5087,7 @@ class ModelReadTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image');
|
$this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image');
|
||||||
$Portfolio = new Portfolio();
|
$Portfolio = new Portfolio();
|
||||||
|
|
||||||
$result = $Portfolio->find(array('id' => 2), null, null, 3);
|
$result = $Portfolio->find('first', array('conditions' => array('id' => 2), 'recursive' => 3));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Portfolio' => array(
|
'Portfolio' => array(
|
||||||
'id' => 2,
|
'id' => 2,
|
||||||
|
@ -5725,7 +5725,7 @@ class ModelReadTest extends BaseModelTest {
|
||||||
$fullDebug = $this->db->fullDebug;
|
$fullDebug = $this->db->fullDebug;
|
||||||
$this->db->fullDebug = true;
|
$this->db->fullDebug = true;
|
||||||
$TestModel->recursive = 6;
|
$TestModel->recursive = 6;
|
||||||
$result = $TestModel->find(array('CategoryThread.id' => 7));
|
$result = $TestModel->find('first', array('conditions' => array('CategoryThread.id' => 7)));
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'CategoryThread' => array(
|
'CategoryThread' => array(
|
||||||
|
@ -6007,12 +6007,12 @@ class ModelReadTest extends BaseModelTest {
|
||||||
function testConditionalNumerics() {
|
function testConditionalNumerics() {
|
||||||
$this->loadFixtures('NumericArticle');
|
$this->loadFixtures('NumericArticle');
|
||||||
$NumericArticle = new NumericArticle();
|
$NumericArticle = new NumericArticle();
|
||||||
$data = array('title' => '12345abcde');
|
$data = array('conditions' => array('title' => '12345abcde'));
|
||||||
$result = $NumericArticle->find($data);
|
$result = $NumericArticle->find('first', $data);
|
||||||
$this->assertTrue(!empty($result));
|
$this->assertTrue(!empty($result));
|
||||||
|
|
||||||
$data = array('title' => '12345');
|
$data = array('conditions' => array('title' => '12345'));
|
||||||
$result = $NumericArticle->find($data);
|
$result = $NumericArticle->find('first', $data);
|
||||||
$this->assertTrue(empty($result));
|
$this->assertTrue(empty($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$result = $Article->save($data);
|
$result = $Article->save($data);
|
||||||
$this->assertFalse(empty($result));
|
$this->assertFalse(empty($result));
|
||||||
|
|
||||||
$testResult = $Article->find(array('Article.title' => 'Test Title'));
|
$testResult = $Article->find('first', array('conditions' => array('Article.title' => 'Test Title')));
|
||||||
|
|
||||||
$this->assertEqual($testResult['Article']['title'], $data['Article']['title']);
|
$this->assertEqual($testResult['Article']['title'], $data['Article']['title']);
|
||||||
$this->assertEqual($testResult['Article']['created'], '2008-01-01 00:00:00');
|
$this->assertEqual($testResult['Article']['created'], '2008-01-01 00:00:00');
|
||||||
|
@ -1019,17 +1019,17 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$Article = new Article();
|
$Article = new Article();
|
||||||
$result = $Article->save(Xml::build('<article title="test xml" user_id="5" />'));
|
$result = $Article->save(Xml::build('<article title="test xml" user_id="5" />'));
|
||||||
$this->assertFalse(empty($result));
|
$this->assertFalse(empty($result));
|
||||||
$results = $Article->find(array('Article.title' => 'test xml'));
|
$results = $Article->find('first', array('conditions' => array('Article.title' => 'test xml')));
|
||||||
$this->assertFalse(empty($results));
|
$this->assertFalse(empty($results));
|
||||||
|
|
||||||
$result = $Article->save(Xml::build('<article><title>testing</title><user_id>6</user_id></article>'));
|
$result = $Article->save(Xml::build('<article><title>testing</title><user_id>6</user_id></article>'));
|
||||||
$this->assertFalse(empty($result));
|
$this->assertFalse(empty($result));
|
||||||
$results = $Article->find(array('Article.title' => 'testing'));
|
$results = $Article->find('first', array('conditions' => array('Article.title' => 'testing')));
|
||||||
$this->assertFalse(empty($results));
|
$this->assertFalse(empty($results));
|
||||||
|
|
||||||
$result = $Article->save(Xml::build('<article><title>testing with DOMDocument</title><user_id>7</user_id></article>', array('return' => 'domdocument')));
|
$result = $Article->save(Xml::build('<article><title>testing with DOMDocument</title><user_id>7</user_id></article>', array('return' => 'domdocument')));
|
||||||
$this->assertFalse(empty($result));
|
$this->assertFalse(empty($result));
|
||||||
$results = $Article->find(array('Article.title' => 'testing with DOMDocument'));
|
$results = $Article->find('first', array('conditions' => array('Article.title' => 'testing with DOMDocument')));
|
||||||
$this->assertFalse(empty($results));
|
$this->assertFalse(empty($results));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1111,7 +1111,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->assertFalse(empty($result));
|
$this->assertFalse(empty($result));
|
||||||
|
|
||||||
$TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
|
$TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
|
||||||
$result = $TestModel->find(array('Article.id' => 2), array('id', 'user_id', 'title', 'body'));
|
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
|
@ -1145,7 +1145,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'belongsTo' => array('User'),
|
'belongsTo' => array('User'),
|
||||||
'hasMany' => array('Comment')
|
'hasMany' => array('Comment')
|
||||||
));
|
));
|
||||||
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body'));
|
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
|
@ -1180,7 +1180,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'belongsTo' => array('User'),
|
'belongsTo' => array('User'),
|
||||||
'hasMany' => array('Comment')
|
'hasMany' => array('Comment')
|
||||||
));
|
));
|
||||||
$result = $TestModel->find(array('Article.id' => 2), array('id', 'user_id', 'title', 'body'));
|
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
|
@ -1227,7 +1227,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'belongsTo' => array('User'),
|
'belongsTo' => array('User'),
|
||||||
'hasMany' => array('Comment')
|
'hasMany' => array('Comment')
|
||||||
));
|
));
|
||||||
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body'));
|
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
|
@ -1250,7 +1250,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'belongsTo' => array('User'),
|
'belongsTo' => array('User'),
|
||||||
'hasMany' => array('Comment')
|
'hasMany' => array('Comment')
|
||||||
));
|
));
|
||||||
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body'));
|
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
|
@ -1290,7 +1290,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'belongsTo' => array('User'),
|
'belongsTo' => array('User'),
|
||||||
'hasMany' => array('Comment')
|
'hasMany' => array('Comment')
|
||||||
));
|
));
|
||||||
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body'));
|
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
|
@ -1330,7 +1330,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'belongsTo' => array('User'),
|
'belongsTo' => array('User'),
|
||||||
'hasMany' => array('Comment')
|
'hasMany' => array('Comment')
|
||||||
));
|
));
|
||||||
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body'));
|
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
|
@ -1372,7 +1372,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'belongsTo' => array('User'),
|
'belongsTo' => array('User'),
|
||||||
'hasMany' => array('Comment')
|
'hasMany' => array('Comment')
|
||||||
));
|
));
|
||||||
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body'));
|
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
|
@ -1414,7 +1414,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'belongsTo' => array('User'),
|
'belongsTo' => array('User'),
|
||||||
'hasMany' => array('Comment')
|
'hasMany' => array('Comment')
|
||||||
));
|
));
|
||||||
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body'));
|
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
|
@ -2987,10 +2987,6 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$db = ConnectionManager::create('mock_transaction', array(
|
$db = ConnectionManager::create('mock_transaction', array(
|
||||||
'datasource' => 'MockTransactionDbo',
|
'datasource' => 'MockTransactionDbo',
|
||||||
));
|
));
|
||||||
$db->expects($this->at(2))
|
|
||||||
->method('isInterfaceSupported')
|
|
||||||
->with('describe')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$db->expects($this->once())
|
$db->expects($this->once())
|
||||||
->method('describe')
|
->method('describe')
|
||||||
|
@ -3026,8 +3022,6 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$db->columns = $testDb->columns;
|
$db->columns = $testDb->columns;
|
||||||
|
|
||||||
$db->expects($this->once())->method('rollback');
|
$db->expects($this->once())->method('rollback');
|
||||||
$db->expects($this->any())->method('isInterfaceSupported')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
$db->expects($this->any())->method('describe')
|
$db->expects($this->any())->method('describe')
|
||||||
->will($this->returnValue(array(
|
->will($this->returnValue(array(
|
||||||
'id' => array('type' => 'integer'),
|
'id' => array('type' => 'integer'),
|
||||||
|
|
Loading…
Reference in a new issue