Changeset 4824

Show
Ignore:
Timestamp:
08/27/08 01:00:16 (5 months ago)
Author:
jwage
Message:

fixes #1221

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/docs/manual/en/searching.txt

    r4674 r4824  
    138138human readable, easy-to-construct search queries to their complex sql equivalents. 
    139139 
     140++ Performing Searches 
     141 
     142Here is a simple example to retrieve the record ids and relevance data. 
     143 
     144<code type="php"> 
     145$results = Doctrine::getTable('Article a')->search('php orm'); 
     146 
     147// Executes the following query and returns an associative array 
     148// SELECT COUNT(keyword) AS relevance, id FROM article_index WHERE id IN (SELECT id FROM article_index WHERE keyword = ?) AND id IN (SELECT id FROM article_index WHERE keyword = ?) GROUP BY id ORDER BY relevance DESC 
     149 
     150print_r($results); // Will print an array of record ids and the relevance of each 
     151</code> 
     152 
     153You can optionally pass the search() function a query object to modify with a where condition subquery to limit the results using the search index. 
     154 
     155<code type="php"> 
     156$query = Doctrine_Query::create() 
     157        ->from('Article a'); 
     158 
     159$articles = Doctrine::getTable('Article a')->search('php orm', $query)->fetchArray(); 
     160 
     161// Executes the following query 
     162// SELECT a.id AS a__id, a.title AS a__title, a.body AS a__body FROM article a WHERE a.id IN(SELECT id FROM article_index WHERE id IN (SELECT id FROM article_index WHERE keyword = ?) && id IN (SELECT id FROM article_index WHERE keyword = ?) GROUP BY id) 
     163 
     164print_r($articles); // Will print the articles which have the keywords php or orm in them. 
     165</code> 
     166 
    140167++ File searches 
    141168