コード例 #1
0
ファイル: notes.php プロジェクト: alerque/bibledit
 /**
  * Searches the notes.
  * Returns an array of note identifiers.
  * $search: Contains the text to search for.
  * $bibles: Array of Bibles the notes should refer to.
  */
 public function searchNotes($search, $bibles)
 {
     $identifiers = array();
     $search = trim($search);
     if ($search == "") {
         return $identifiers;
     }
     // SQL SELECT statement.
     $query = Filter_Sql::notesSelectIdentifier();
     // SQL fulltext search statement sorted on relevance.
     $query .= Filter_Sql::notesOptionalFulltextSearchRelevanceStatement($search);
     // SQL FROM ... WHERE statement.
     $query .= Filter_Sql::notesFromWhereStatement();
     // Consider text contained in notes.
     $query .= Filter_Sql::notesOptionalFulltextSearchStatement($search);
     // Consider Bible constraints:
     // * A user has access to notes that refer to Bibles the user has access to.
     // * A note can be a general one, not referring to any specific Bible.
     //   Select such notes also.
     $bibles[] = "";
     $query .= " AND (bible = '' ";
     foreach ($bibles as $bible) {
         $bible = Database_SQLiteInjection::no($bible);
         $query .= " OR bible = '{$bible}' ";
     }
     $query .= " ) ";
     // Notes get ordered on relevance of search hits.
     $query .= Filter_Sql::notesOrderByRelevanceStatement();
     // Complete query.
     $query .= ";";
     $db = self::connect();
     $result = Database_SQLite::query($db, $query);
     foreach ($result as $row) {
         $identifiers[] = $row[0];
     }
     unset($db);
     return $identifiers;
 }
コード例 #2
0
ファイル: sqlTest.php プロジェクト: alerque/bibledit
 public function testOrderByRelevanceStatement()
 {
     $this->assertEquals("", Filter_Sql::notesOrderByRelevanceStatement());
 }