// Smersh // // Douglas Thrift // // $Id$ #include "Person.hpp" Person::Person(const string& sn) : name("Unknown Person") { if (driver.empty()) configure(); if (!sn.empty()) query(sn); } string Person::driver, Person::host, Person::user, Person::password, Person::db; void Person::configure() { ext::Handle document(xml::Parse("smersh.xml")); ext::Handle smersh(*document/"smersh"); driver = ext::String(*smersh/"driver"); host = ext::String(*smersh/"host"); user = ext::String(*smersh/"user"); password = ext::String(*smersh/"password"); db = ext::String(*smersh/"db"); if (Smersh::debug) std::cerr << "driver = " << driver << "\nhost = " << host << '\n' << "user = " << user << "\npassword = " << password << "\ndb = " << db << '\n'; } void Person::query(const string& sn) { ext::Handle driver(dbi::GetDriver(this->driver)); ext::Handle db(driver->Connect(host, user, password, this->db)); ext::Handle people(db->Execute("SELECT name FROM people, " "peopleaimmap, aim WHERE people.id=pid AND aid=aim.id AND sn=LOWER(\'" + sn + "\')")); if (people->MoveNext()) name = people->GetString("name"); while (people->MoveNext()) { Person person; person.name = people->GetString("name"); multiple.InsertLast(person); } }