From 08bec6858739324db49e92a2341bd856c95b1d16 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 17 Oct 2007 21:17:01 +0000 Subject: [PATCH] --- lib/Doctrine/Search.php | 8 +++---- lib/Doctrine/Search/Query.php | 34 ++++++++-------------------- lib/Doctrine/Template/Searchable.php | 6 ++--- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/lib/Doctrine/Search.php b/lib/Doctrine/Search.php index c63386120..1d43a9b39 100644 --- a/lib/Doctrine/Search.php +++ b/lib/Doctrine/Search.php @@ -66,9 +66,9 @@ class Doctrine_Search extends Doctrine_Plugin { $q = new Doctrine_Search_Query($this->_options['pluginTable']); - $q->search($query); + $q->query($query); - return $q->execute(); + return $this->_options['connection']->fetchAll($q->getSql(), $q->getParams());; } public function analyze($text) @@ -145,7 +145,7 @@ class Doctrine_Search extends Doctrine_Plugin - public function processPending($limit = null, $offset = null) + public function batchUpdateIndex($limit = null, $offset = null) { $this->buildDefinition(); @@ -215,8 +215,6 @@ class Doctrine_Search extends Doctrine_Plugin return false; } - - $columns = array('keyword' => array('type' => 'string', 'length' => 200, 'primary' => true, diff --git a/lib/Doctrine/Search/Query.php b/lib/Doctrine/Search/Query.php index 195c20476..9f4ad861b 100644 --- a/lib/Doctrine/Search/Query.php +++ b/lib/Doctrine/Search/Query.php @@ -32,10 +32,7 @@ */ class Doctrine_Search_Query { - /** - * @var Doctrine_Query $query the base query - */ - protected $_query; + /** * @var Doctrine_Table $_table the index table */ @@ -48,35 +45,30 @@ class Doctrine_Search_Query protected $_condition; /** - * @param octrine_Table $_table the index table + * @param Doctrine_Table $_table the index table */ public function __construct($table) { if (is_string($table)) { $table = Doctrine_Manager::table($table); + } else { + if ( ! $table instanceof Doctrine_Table) { + throw new Doctrine_Search_Exception('Invalid argument type. Expected instance of Doctrine_Table.'); + } } $this->_table = $table; - $this->_query = new Doctrine_Query(); $foreignId = current(array_diff($this->_table->getColumnNames(), array('keyword', 'field', 'position'))); $this->_condition = $foreignId . ' %s (SELECT ' . $foreignId . ' FROM ' . $this->_table->getTableName() . ' WHERE '; } - /** - * getQuery - * - * @return Doctrine_Query returns the query object associated with this object - */ - public function getQuery() - { - return $this->_query; - } - public function search($text) + + public function query($text) { $text = trim($text); - + $foreignId = current(array_diff($this->_table->getColumnNames(), array('keyword', 'field', 'position'))); $weighted = false; @@ -228,10 +220,4 @@ class Doctrine_Search_Query { return $this->_sql; } - public function execute() - { - $resultSet = $this->_query->execute(); - - return $resultSet; - } -} \ No newline at end of file +} diff --git a/lib/Doctrine/Template/Searchable.php b/lib/Doctrine/Template/Searchable.php index b18b69bb0..75954249e 100644 --- a/lib/Doctrine/Template/Searchable.php +++ b/lib/Doctrine/Template/Searchable.php @@ -61,9 +61,9 @@ class Doctrine_Template_Searchable extends Doctrine_Template $this->addListener(new Doctrine_Search_Listener($this->_plugin)); } - - public function processPending($limit = null, $offset = null) + + public function batchUpdateIndex($limit = null, $offset = null) { - $this->_plugin->processPending($limit, $offset); + $this->_plugin->batchUpdateIndex($limit, $offset); } }