1
0
mirror of synced 2024-12-14 07:06:04 +03:00

refactored parameter stacking (Fixes #442).

This commit is contained in:
romanb 2007-09-02 09:28:38 +00:00
parent 0fdb229020
commit af2a83484f
6 changed files with 28 additions and 27 deletions

View File

@ -70,7 +70,9 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
/**
* @var array $params query input parameters
*/
protected $_params = array();
protected $_params = array('where' => array(),
'set' => array(),
'having' => array());
/**
* @var Doctrine_Connection $conn Doctrine_Connection object
*/
@ -688,7 +690,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
*/
public function getParams()
{
return $this->_params;
return array_merge($this->_params['set'], $this->_params['where'], $this->_params['having']);
}
/**
* setParams
@ -751,7 +753,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
}
public function _execute($params)
{
$params = $this->_conn->convertBooleans(array_merge($this->_params, $params));
$params = $this->_conn->convertBooleans($params);
if ( ! $this->_view) {
$query = $this->getQuery($params);
@ -783,6 +785,8 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
*/
public function execute($params = array(), $hydrationMode = null)
{
$params = array_merge($this->_params['set'], $this->_params['where'],
$this->_params['having'], $params);
if ($this->_cache) {
$cacheDriver = $this->getCacheDriver();
@ -1036,10 +1040,9 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$oneToOne = false;
$index = $driver->search($element, $array);
if ($index === false) {
$key = $map['map'];
if (isset($key)) {
if ($index === false) {
if (isset($map['map'])) {
$key = $map['map'];
if (isset($array[$key])) {
throw new Doctrine_Hydrate_Exception("Couldn't hydrate. Found non-unique key mapping.");
}
@ -1081,9 +1084,8 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$index = $driver->search($element, $prev[$parent][$componentAlias]);
if ($index === false) {
$key = $map['map'];
if (isset($key)) {
if (isset($map['map'])) {
$key = $map['map'];
if (isset($prev[$parent][$componentAlias][$key])) {
throw new Doctrine_Hydrate_Exception("Couldn't hydrate. Found non-unique key mapping.");
}

View File

@ -1519,7 +1519,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$params = array($params);
}
// append parameters
$params = array_merge($this->_params, $params);
$params = array_merge($this->_params['where'], $this->_params['having'], $params);
$results = $this->getConnection()->fetchAll($q, $params);

View File

@ -65,9 +65,9 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
public function addWhere($where, $params = array())
{
if (is_array($params)) {
$this->_params = array_merge($this->_params, $params);
$this->_params['where'] = array_merge($this->_params['where'], $params);
} else {
$this->_params[] = $params;
$this->_params['where'][] = $params;
}
return $this->parseQueryPart('where', $where, true);
}
@ -93,7 +93,7 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
$a[] = $value;
}
$this->_params = array_merge($this->_params, $params);
$this->_params['where'] = array_merge($this->_params['where'], $params);
$where = $expr . ' IN (' . implode(', ', $a) . ')';
@ -121,9 +121,9 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
public function addHaving($having, $params = array())
{
if (is_array($params)) {
$this->_params = array_merge($this->_params, $params);
$this->_params['having'] = array_merge($this->_params['having'], $params);
} else {
$this->_params[] = $params;
$this->_params['having'][] = $params;
}
return $this->parseQueryPart('having', $having, true);
}
@ -217,9 +217,9 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
} else {
if ($params !== null) {
if (is_array($params)) {
$this->_params = array_merge($this->_params, $params);
$this->_params['set'] = array_merge($this->_params['set'], $params);
} else {
$this->_params[] = $params;
$this->_params['set'][] = $params;
}
}
return $this->parseQueryPart('set', $key . ' = ' . $value, true);
@ -279,11 +279,11 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
*/
public function where($where, $params = array())
{
//$this->_params = array();
$this->_params['where'] = array();
if (is_array($params)) {
$this->_params = $params;
$this->_params['where'] = $params;
} else {
$this->_params[] = $params;
$this->_params['where'][] = $params;
}
return $this->parseQueryPart('where', $where);
@ -298,11 +298,11 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
*/
public function having($having, $params = array())
{
$this->_params = array();
$this->_params['having'] = array();
if (is_array($params)) {
$this->_params = $params;
$this->_params['having'] = $params;
} else {
$this->_params[] = $params;
$this->_params['having'][] = $params;
}
return $this->parseQueryPart('having', $having);

View File

@ -139,7 +139,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$class = get_class($this);
// get the table of this class
$this->_table = Doctrine_Manager::getInstance()
->getTable(get_class($this));
->getTable($class);
$exists = false;
}

View File

@ -110,7 +110,7 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
$conn = $this->_table->getConnection();
foreach ($map as $key => $value) {
$table = $conn->getTable($key);
// $table->setOption('inheritanceMap', $value);
$table->setOption('inheritanceMap', $value);
}
}

View File

@ -74,7 +74,6 @@ $test->addTestCase(new Doctrine_Ticket330_TestCase());
$test->addTestCase(new Doctrine_TicketNjero_TestCase());
// Connection drivers (not yet fully tested)
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());