From 6b26a7b8139f67d903fd1d3c04700f84be6425a4 Mon Sep 17 00:00:00 2001 From: adamthehutt Date: Mon, 8 Oct 2007 16:39:12 +0000 Subject: [PATCH] Fix for ticket #457, moves Doctrine_Record::find/One() to Doctrine_Table::execute/One() Ticket: 457 --- lib/Doctrine/Record.php | 39 ------------------------------ lib/Doctrine/Table.php | 41 ++++++++++++++++++++++++++++++++ tests/Query/RegistryTestCase.php | 2 +- 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 2ad81b807..66ebe15e7 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -1421,45 +1421,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count } } - /** - * fetch - * fetches data using the provided queryKey and - * the associated query in the query registry - * - * if no query for given queryKey is being found a - * Doctrine_Query_Registry exception is being thrown - * - * @param string $queryKey the query key - * @param array $params prepared statement params (if any) - * @return mixed the fetched data - */ - public function find($queryKey, $params = array(), $hydrationMode = Doctrine::HYDRATE_RECORD) - { - return Doctrine_Manager::getInstance() - ->getQueryRegistry() - ->get($queryKey, $this->_table->getComponentName()) - ->execute($params, $hydrationMode); - } - /** - * fetchOne - * fetches data using the provided queryKey and - * the associated query in the query registry - * - * if no query for given queryKey is being found a - * Doctrine_Query_Registry exception is being thrown - * - * @param string $queryKey the query key - * @param array $params prepared statement params (if any) - * @return mixed the fetched data - */ - public function findOne($queryKey, $params = array(), $hydrationMode = Doctrine::HYDRATE_RECORD) - { - return Doctrine_Manager::getInstance() - ->getQueryRegistry() - ->get($queryKey, $this->_table->getComponentName()) - ->fetchOne($params, $hydrationMode); - } - /** * call * diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index 94450284a..17f849148 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -886,6 +886,47 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { return $this->findBySql($dql, $params, $hydrationMode); } + + /** + * execute + * fetches data using the provided queryKey and + * the associated query in the query registry + * + * if no query for given queryKey is being found a + * Doctrine_Query_Registry exception is being thrown + * + * @param string $queryKey the query key + * @param array $params prepared statement params (if any) + * @return mixed the fetched data + */ + public function execute($queryKey, $params = array(), $hydrationMode = Doctrine::HYDRATE_RECORD) + { + return Doctrine_Manager::getInstance() + ->getQueryRegistry() + ->get($queryKey, $this->getComponentName()) + ->execute($params, $hydrationMode); + } + + /** + * executeOne + * fetches data using the provided queryKey and + * the associated query in the query registry + * + * if no query for given queryKey is being found a + * Doctrine_Query_Registry exception is being thrown + * + * @param string $queryKey the query key + * @param array $params prepared statement params (if any) + * @return mixed the fetched data + */ + public function executeOne($queryKey, $params = array(), $hydrationMode = Doctrine::HYDRATE_RECORD) + { + return Doctrine_Manager::getInstance() + ->getQueryRegistry() + ->get($queryKey, $this->getComponentName()) + ->fetchOne($params, $hydrationMode); + } + /** * clear * clears the first level cache (identityMap) diff --git a/tests/Query/RegistryTestCase.php b/tests/Query/RegistryTestCase.php index ddbaedea5..aaef888f7 100644 --- a/tests/Query/RegistryTestCase.php +++ b/tests/Query/RegistryTestCase.php @@ -62,6 +62,6 @@ class Doctrine_Query_Registry_TestCase extends Doctrine_UnitTestCase $user = new User(); - $user->find('all'); + $user->getTable()->execute('all'); } }