Changeset 990afd5 for src/sql


Ignore:
Timestamp:
01/20/10 15:50:12 (12 years ago)
Author:
timkoma <timkoma@…>
Branches:
master, qt5
Children:
f2ef735
Parents:
b1a201a
Message:

temp commit for search tab

Location:
src/sql
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sql/sqlengine.cpp

    rb1a201a r990afd5  
    290290}
    291291
     292int SqlEngine::searchEvent(int aConferenceId, const QList<QString> &aColumns, const QString &aKeyword)
     293{
     294    QSqlDatabase db = QSqlDatabase::database();
     295
     296    if ( !db.isValid() || !db.isOpen())
     297        return -1;
     298
     299    QString query = QString(
     300        "DROP TABLE IF EXISTS SEARCH_EVENT;"
     301        "CREATE TEMP TABLE SEARCH_EVENT ( xid_conference INTEGER  NOT NULL, id INTEGER NOT NULL );"
     302        "INSERT INTO SEARCH_EVENT ( xid_conference, id) "
     303            "SELECT xid_conference, id FROM EVENT AS e INNER JOIN VIRTUAL_EVENT AS ve USING (xid_conference, id) "
     304            "WHERE xid_conference = %1 AND (").arg( aConferenceId );
     305
     306    int i = 0;
     307    foreach (QString str, aColumns){
     308        query += QString("%1 LIKE '\%%2\%' OR ").arg( aColumns.at(i++), aKeyword );
     309    }
     310    query.chop( QString(" OR ").length() );
     311    query += QString(");");
     312
     313    qDebug() << "\nSQL: " << query;
     314
     315    db.exec();
     316
     317    if( db.lastError().isValid() && db.lastError().number() != 0 ){
     318        qDebug() << "SQL ERR: " << db.lastError().number() << ", " << db.lastError().text();
     319        return 0;
     320    }
     321    else{
     322        qDebug() << "SQL OK.\n";
     323        return 1;
     324    }
     325
     326}
  • src/sql/sqlengine.h

    rb1a201a r990afd5  
    1919        void addLinkToDB(QHash<QString,QString> &aLink);
    2020        void addRoomToDB(QHash<QString,QString> &aRoom);
     21
     22        // search Events for ....
     23        int searchEvent(int conferenceId, const QList<QString> &columns, const QString &keyword);
    2124    private:
    2225        QString login(const QString &aDatabaseType, const QString &aDatabaseName);
Note: See TracChangeset for help on using the changeset viewer.