Changeset c7b58d4 for src/sql


Ignore:
Timestamp:
01/25/10 14:05:23 (12 years ago)
Author:
timkoma <timkoma@…>
Branches:
master, qt5
Children:
1deea3b
Parents:
7620de0
Message:

search upgrade

Location:
src/sql
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sql/sqlengine.cpp

    r7620de0 rc7b58d4  
    307307}
    308308
    309 int SqlEngine::searchEvent(int aConferenceId, const QList<QString> &aColumns, const QString &aKeyword)
     309int SqlEngine::searchEvent(int aConferenceId, const QHash<QString,QString> &aColumns, const QString &aKeyword)
    310310{
    311311    QSqlDatabase db = QSqlDatabase::database();
     
    321321    // INSERT
    322322    QString query = QString("INSERT INTO SEARCH_EVENT ( xid_conference, id) "
    323                 "SELECT xid_conference, id FROM EVENT "
    324                 "WHERE xid_conference = %1 AND (").arg( aConferenceId );
    325     int i = 0;
    326     foreach (QString str, aColumns){
    327         query += QString("%1 LIKE '\%%2\%' OR ").arg( aColumns.at(i++), aKeyword );
     323                "SELECT EVENT.xid_conference, EVENT.id FROM EVENT ");
     324    if( aColumns.contains("ROOM") ){
     325        query += "INNER JOIN EVENT_ROOM ON (EVENT.xid_conference = EVENT_ROOM.xid_conference AND EVENT.id = EVENT_ROOM.xid_event ) ";
     326        query += "INNER JOIN ROOM ON ( EVENT_ROOM.xid_room = ROOM.id ) ";
     327    }
     328    if( aColumns.contains("PERSON") ){
     329        query += "INNER JOIN EVENT_PERSON ON (EVENT.xid_conference = EVENT_PERSON.xid_conference AND EVENT.id = EVENT_PERSON.xid_event ) ";
     330        query += "INNER JOIN PERSON ON ( EVENT_PERSON.xid_person = PERSON.id ) ";
     331    }
     332    query += QString("WHERE EVENT.xid_conference = %1 AND (").arg( aConferenceId );
     333
     334    foreach (QString table, aColumns.uniqueKeys()){
     335        foreach (QString column, aColumns.values(table)){
     336            query += QString("%1.%2 LIKE '\%%3\%' OR ").arg( table, column, aKeyword );
     337        }
    328338    }
    329339    query.chop( QString(" OR ").length() );
  • src/sql/sqlengine.h

    r7620de0 rc7b58d4  
    2121
    2222        // search Events for ....
    23         int searchEvent(int conferenceId, const QList<QString> &columns, const QString &keyword);
     23        int searchEvent(int conferenceId, const QHash<QString,QString> &columns, const QString &keyword);
    2424    private:
    2525        QString login(const QString &aDatabaseType, const QString &aDatabaseName);
Note: See TracChangeset for help on using the changeset viewer.