Moved logic to run the query out of the constructor.
This commit is contained in:
parent
0f2a3353a1
commit
b39a6163e8
1 changed files with 21 additions and 7 deletions
|
@ -9,7 +9,7 @@
|
|||
* Redistribution of these files must retain the above copyright notice.
|
||||
*
|
||||
* @author Josh Sherman <josh@gravityblvd.com>
|
||||
* @copyright Copyright 2007-2011, Josh Sherman
|
||||
* @copyright Copyright 2007-2011, Josh Sherman
|
||||
* @license http://www.opensource.org/licenses/mit-license.html
|
||||
* @package PICKLES
|
||||
* @link http://p.ickl.es
|
||||
|
@ -244,9 +244,7 @@ class Model extends Object
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Creates a new (empty) object or creates the record set from the passed
|
||||
* arguments. The record and records arrays are populated as well as the
|
||||
* count variable.
|
||||
* Creates a new (empty) object or populates the record set.
|
||||
*
|
||||
* @param mixed $type_or_parameters optional type of query or parameters
|
||||
* @param array $parameters optional data to create a query from
|
||||
|
@ -260,12 +258,28 @@ class Model extends Object
|
|||
// @todo Datasource has no way of being set
|
||||
$this->db = Database::getInstance($this->datasource != '' ? $this->datasource : null);
|
||||
$this->caching = $this->db->getCache();
|
||||
|
||||
|
||||
if ($this->caching)
|
||||
{
|
||||
$this->cache = Cache::getInstance();
|
||||
}
|
||||
|
||||
return $this->execute($type_or_parameters, $parameters);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ Database Execution Methods
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* Potentially populates the record set from the passed arguments.
|
||||
*
|
||||
* @param mixed $type_or_parameters optional type of query or parameters
|
||||
* @param array $parameters optional data to create a query from
|
||||
*/
|
||||
public function execute($type_or_parameters = null, $parameters = null)
|
||||
{
|
||||
// Builds out the query
|
||||
if ($type_or_parameters != null)
|
||||
{
|
||||
|
@ -886,7 +900,7 @@ class Model extends Object
|
|||
if ($this->iterate == false)
|
||||
{
|
||||
$this->iterate = true;
|
||||
|
||||
|
||||
// Resets the records, saves calling reset() when walking multiple times
|
||||
$this->reset();
|
||||
}
|
||||
|
@ -953,7 +967,7 @@ class Model extends Object
|
|||
{
|
||||
$sql .= ' WHERE ' . $this->id . ' = :' . $this->id . ' LIMIT 1;';
|
||||
$input_parameters[':' . $this->id] = $this->record[$this->id];
|
||||
|
||||
|
||||
if ($this->caching)
|
||||
{
|
||||
//$this->cache->delete('PICKLES-' . $this->datasource . '-' . $this->table . '-' . $this->record[$this->id]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue