Changeset 15836 for gsdl/trunk/lib/sqlitedbclass.cpp
- Timestamp:
- 2008-05-30T16:00:47+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/lib/sqlitedbclass.cpp
r15811 r15836 100 100 // returns array of document OIDs 101 101 text_tarray sqlitedbclass::get_documents_with_metadata_value (const text_t &metadata_element_name, 102 const text_t &metadata_value) 102 const text_t &metadata_value, 103 const text_t &sort_by_metadata_element_name) 103 104 { 104 105 text_tarray document_OIDs; … … 111 112 112 113 // Get the entries in the "document_metadata" table where the element and value matches those specified 113 text_t sql_cmd = "SELECT docOID FROM document_metadata WHERE element='" + metadata_element_name + "' AND value='" + metadata_value + "'"; 114 text_t sql_cmd; 115 if (sort_by_metadata_element_name == "") 116 { 117 // No sorting required 118 sql_cmd = "SELECT docOID FROM document_metadata WHERE element='" + metadata_element_name + "' AND value='" + metadata_value + "'"; 119 } 120 else 121 { 122 // Sort the documents by a certain metadata element 123 // John Thompson thinks this may not be the most efficient solution, and recommends using ON instead of WHERE 124 sql_cmd = "SELECT b.docOID FROM document_metadata AS a LEFT JOIN document_metadata AS b USING (docOID) WHERE a.element='" + metadata_element_name + "' AND a.value='" + metadata_value + "' AND b.element='" + sort_by_metadata_element_name + "' ORDER BY b.value"; 125 } 114 126 vector<text_tmap> sql_results; 115 127 if (!sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0)
Note:
See TracChangeset
for help on using the changeset viewer.