ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/DecentralizedMedia/MediaFile.cpp
(Generate patch)

Comparing DecentralizedMedia/MediaFile.cpp (file contents):
Revision 554 by douglas, 2005-07-07T04:24:27-07:00 vs.
Revision 555 by douglas, 2005-07-10T21:18:35-07:00

# Line 10 | Line 10
10  
11   #include "MediaFile.hpp"
12  
13 < MediaFile::MediaFile(const _R<dbi::Connection>& connection, const api::Path& path) : connection(connection), path(path)
13 > MediaFile::MediaFile(const _R<Connector>& connector, const api::Path& path) : connector(connector), path(path)
14   {
15 +        _R<dbi::Connection> connection(connector->Connect());
16          _R<dbi::ResultSet> info(connection->Parse(_B("SELECT artist, title, album, genre FROM files WHERE path = ?"))->Execute(path.GetPath()));
17  
18          if (info->MoveNext())
# Line 21 | Line 22 | MediaFile::MediaFile(const _R<dbi::Conne
22                  album = info->GetString(_B("album"));
23                  genre = info->GetString(_B("genre"));
24          }
25 +
26 +        connector->Release(connection);
27   }
28  
29 < MediaFile::MediaFile(const _R<dbi::Connection>& connection, const api::Path& path, const cse::String& artist, const cse::String& title, const cse::String& album, const cse::String& genre, const api::Path& root) : connection(connection), path(path), artist(artist), title(title), album(album), genre(genre)
29 > MediaFile::MediaFile(const _R<Connector>& connector, const api::Path& path, const cse::String& artist, const cse::String& title, const cse::String& album, const cse::String& genre, const api::Path& root) : connector(connector), path(path), artist(artist), title(title), album(album), genre(genre)
30   {
31 +        _R<dbi::Connection> connection(connector->Connect());
32          _R<dbi::ResultSet> path_(connection->Parse(_B("SELECT path FROM files WHERE path = ?"))->Execute(path.GetPath()));
33  
34          if (path_->MoveNext())
# Line 47 | Line 51 | MediaFile::MediaFile(const _R<dbi::Conne
51          }
52          else
53                  connection->Parse(_B("INSERT INTO files (path, artist, title, album, genre, folder, root) VALUES (?, ?, ?, ?, ?, ?, ?)"))->Execute(path.GetPath(), artist, title, album, genre, path.GetParent().GetPath(), root.GetPath());
54 +
55 +        connector->Release(connection);
56   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines