Fixed issue when passing in single IDs

If you tried to use the extended array syntax to query against the primary key (id) and passed it an integer instead of an array, an error was occurring. Thanks @geoffoliver !
This commit is contained in:
Josh Sherman 2013-09-22 22:48:07 -04:00
parent 6ac911b78a
commit 7ed930d278

View file

@ -432,6 +432,11 @@ class Model extends Object
$cache_keys = array(); $cache_keys = array();
$sorted_records = array(); $sorted_records = array();
if (!is_array($type_or_parameters['conditions'][$this->columns['id']]))
{
$type_or_parameters['conditions'][$this->columns['id']] = array($type_or_parameters['conditions'][$this->columns['id']]);
}
foreach ($type_or_parameters['conditions'][$this->columns['id']] as $id) foreach ($type_or_parameters['conditions'][$this->columns['id']] as $id)
{ {
$cache_keys[] = strtoupper($this->model) . '-' . $id; $cache_keys[] = strtoupper($this->model) . '-' . $id;