Changeset 12042


Ignore:
Timestamp:
09/08/11 21:49:58 (13 years ago)
Author:
tbretz
Message:
Added program name to call of parse_database; fixed database query; removed setting 'unregistered' option - this is done in a later step by boost itself
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Configuration.cc

    r11769 r12042  
    391391#ifdef HAS_SQL
    392392po::basic_parsed_options<char>
    393     Configuration::parse_database(const string &database, const po::options_description& desc, bool allow_unregistered)
     393    Configuration::parse_database(const string &prgname, const string &database, const po::options_description& desc, bool allow_unregistered)
    394394{
    395395    //static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))?");
     
    422422    if (!db.empty())
    423423        cout << "/" << db;
    424     cout << "'" << endl;
     424    cout << "' for " << prgname << endl;
    425425
    426426    mysqlpp::Connection conn(db.c_str(), server.c_str(), user.c_str(), passwd.c_str(), port);
     
    433433
    434434    const mysqlpp::StoreQueryResult res =
    435         conn.query("SELECT fProgram, CONCAT(fKey1,fKey2), fValue "
    436                    "FROM ProgramOption WHERE fCounter="
    437                    "(SELECT MAX(fCounter) FROM History)").store();
     435        conn.query("SELECT CONCAT(fKey1,fKey2), fValue "
     436                   "FROM ProgramOption "
     437                   "WHERE fCounter=(SELECT MAX(fCounter) FROM History) "
     438                   "AND (fProgram='"+prgname+"' OR fProgram='*')").store();
    438439    /* throws exceptions
    439440    if (!res)
     
    477478        n.value.clear();          // Fixme: composing?
    478479        n.value.push_back((*v)[1].c_str());
    479         n.unregistered = unregistered;
     480        //n.unregistered = unregistered;
    480481
    481482        // If any parsing will be done in the future...
     
    487488    }
    488489
    489     cout << endl;
    490 
    491490    return result;
    492491}
    493492#else
    494493po::basic_parsed_options<char>
    495     Configuration::parse_database(const string &, const po::options_description &desc, bool)
     494    Configuration::parse_database(const string &, const string &, const po::options_description &desc, bool)
    496495{
    497496    return po::parsed_options(&desc);
     
    11461145    {
    11471146        fDatabase = getdatabase["database"].as<string>();
    1148         cerr << "Requesting options from '" << fDatabase << "'." << endl;
     1147        cerr << "Requesting options from database for '" << fName << "'" << endl;
    11491148    }
    11501149
     
    11531152    const po::parsed_options parsed_database =
    11541153        fDatabase.empty() ? po::parsed_options(&opt_database) :
    1155         parse_database(fDatabase, opt_database, !checkdb);
     1154        parse_database(path.filename(), fDatabase, opt_database, !checkdb);
    11561155
    11571156    // ------------------------ (11) -------------------------
Note: See TracChangeset for help on using the changeset viewer.