ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Smersh/Person.cpp
Revision: 349
Committed: 2004-12-16T18:15:34-08:00 (20 years, 6 months ago) by douglas
File size: 1330 byte(s)
Log Message:
Horribly broken, including parts of menes.

File Contents

# User Rev Content
1 Douglas Thrift 164 // Smersh
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #include "Person.hpp"
8    
9 Douglas Thrift 167 Person::Person(const string& sn) : name("Unknown Person")
10 Douglas Thrift 164 {
11 Douglas Thrift 183 if (driver.empty()) configure();
12 Douglas Thrift 170 if (!sn.empty()) query(sn);
13     }
14    
15 Douglas Thrift 183 string Person::driver, Person::host, Person::user, Person::password, Person::db;
16 Douglas Thrift 170
17     void Person::configure()
18     {
19     ext::Handle<xml::Document> document(xml::Parse("smersh.xml"));
20     ext::Handle<xml::Node> smersh(*document/"smersh");
21    
22 Douglas Thrift 238 driver = ext::String(*smersh/"driver");
23     host = ext::String(*smersh/"host");
24     user = ext::String(*smersh/"user");
25     password = ext::String(*smersh/"password");
26     db = ext::String(*smersh/"db");
27 Douglas Thrift 179
28 douglas 349 if (Smersh::debug) std::cerr << "driver = " << driver << "\nhost = " << host << '\n'
29 Douglas Thrift 183 << "user = " << user << "\npassword = " << password << "\ndb = " << db
30     << '\n';
31 Douglas Thrift 164 }
32 Douglas Thrift 170
33     void Person::query(const string& sn)
34     {
35 Douglas Thrift 253 ext::Handle<dbi::Driver> driver(dbi::GetDriver(this->driver));
36     ext::Handle<dbi::Connection> db(driver->Connect(host, user, password,
37 Douglas Thrift 183 this->db));
38 Douglas Thrift 253 ext::Handle<dbi::ResultSet> people(db->Execute("SELECT name FROM people, "
39     "peopleaimmap, aim WHERE people.id=pid AND aid=aim.id AND sn=LOWER(\'"
40     + sn + "\')"));
41 Douglas Thrift 179
42     if (people->MoveNext()) name = people->GetString("name");
43    
44     while (people->MoveNext())
45     {
46     Person person;
47    
48     person.name = people->GetString("name");
49    
50 douglas 349 multiple.InsertLast(person);
51 Douglas Thrift 179 }
52 Douglas Thrift 170 }

Properties

Name Value
svn:eol-style native
svn:keywords Id