ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Smersh/Person.cpp
Revision: 238
Committed: 2004-09-10T16:28:13-07:00 (20 years, 9 months ago) by Douglas Thrift
File size: 1272 byte(s)
Log Message:
Meep!

File Contents

# Content
1 // Smersh
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #include "Person.hpp"
8
9 Person::Person(const string& sn) : name("Unknown Person")
10 {
11 if (driver.empty()) configure();
12 if (!sn.empty()) query(sn);
13 }
14
15 string Person::driver, Person::host, Person::user, Person::password, Person::db;
16
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 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
28 if (debug) cerr << "driver = " << driver << "\nhost = " << host << '\n'
29 << "user = " << user << "\npassword = " << password << "\ndb = " << db
30 << '\n';
31 }
32
33 void Person::query(const string& sn)
34 {
35 ext::Handle<dbi::Connection> db(dbi::Connect(driver, host, user, password,
36 this->db));
37 ext::Handle<dbi::ResultSet> people(db->Execute(string("SELECT name FROM pe")
38 + "ople, peopleaimmap, aim WHERE people.id=pid AND aid=aim.id AND sn=LO"
39 + "WER(\'" + sn + "\')"));
40
41 if (people->MoveNext()) name = people->GetString("name");
42
43 while (people->MoveNext())
44 {
45 Person person;
46
47 person.name = people->GetString("name");
48
49 multiple.push_back(person);
50 }
51 }

Properties

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