From 999e03fd59dc3d00307c9d59c0e1038bb1079335 Mon Sep 17 00:00:00 2001 From: zYne Date: Sat, 29 Sep 2007 15:00:08 +0000 Subject: [PATCH] --- lib/Doctrine/Search.php | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/Search.php b/lib/Doctrine/Search.php index f09535019..faa73cc0c 100644 --- a/lib/Doctrine/Search.php +++ b/lib/Doctrine/Search.php @@ -95,19 +95,49 @@ class Doctrine_Search } } } + + public function processPendingTable($tableName, $indexTableName, array $fields, $id, $conn = null) + { + if ( ! ($conn instanceof Doctrine_Connection)) { + $conn = Doctrine_Manager::connection(); + } + $fields = array_merge($fields, array($id)); + $query = 'SELECT ' . implode(', ', $fields) . ' FROM ' . $tableName . ' WHERE ' + . $id . ' IN (SELECT foreign_id FROM ' + . $indexTableName + . ') ORDER BY ' . $id; + + $data = $conn->fetchAll($query); + + foreach ($data as $row) { + $identifier = $row[$id]; + + unset($row[$id]); + + foreach ($row as $field => $data) { + $terms = $this->analyze($data); + + foreach ($terms as $pos => $term) { + $conn->insert($indexTableName, array('keyword' => $field, + 'position' => $pos, + 'field' => $field, + 'foreign_id' => $identifier); + } + } + } + } /** - * savePending + * insertPending * - * @param Doctrine_Record $record * @return integer */ - public function savePending($tableName, $id, $conn = null) + public function insertPending($indexTableName, $id, $conn = null) { if ( ! ($conn instanceof Doctrine_Connection)) { $conn = Doctrine_Manager::connection(); } - $conn->insert($tableName, array('foreign_id' => $id)); + $conn->insert($indexTableName, array('foreign_id' => $id)); } public function buildDefinition(Doctrine_Table $table) {