10 |
|
|
11 |
|
#include "Library.hpp" |
12 |
|
|
13 |
< |
Library::Library(const _R<dbi::Connection>& connection) : connection(connection) |
13 |
> |
Library::Library(const _R<Connector>& connector) : connector(connector) |
14 |
|
{ |
15 |
+ |
_R<dbi::Connection> connection(connector->Connect()); |
16 |
+ |
|
17 |
|
connection->Execute(_B("UPDATE files SET live = FALSE")); |
18 |
+ |
|
19 |
+ |
connector->Release(connection); |
20 |
|
} |
21 |
|
|
22 |
|
_L<MediaFolder> Library::GetFolders(unsigned page) const |
23 |
|
{ |
24 |
+ |
_R<dbi::Connection> connection(connector->Connect()); |
25 |
|
_R<dbi::ResultSet> roots(connection->Parse(_B("SELECT DISTINCT root FROM files WHERE live = TRUE ORDER By root LIMIT 50 OFFSET ?"))->Execute(page * 50)); |
26 |
|
_L<MediaFolder> folders; |
27 |
|
|
28 |
|
while (roots->MoveNext()) |
29 |
|
folders.InsertLast(GetFolder(roots->GetString(_B("root")))); |
30 |
|
|
31 |
+ |
connector->Release(connection); |
32 |
+ |
|
33 |
|
return folders; |
34 |
|
} |
35 |
|
|
47 |
|
|
48 |
|
statement_ << _B("ORDER BY path LIMIT 50 OFFSET ?"); |
49 |
|
|
50 |
+ |
_R<dbi::Connection> connection(connector->Connect()); |
51 |
|
_R<dbi::Statement> statement(connection->Parse(statement_)); |
52 |
|
|
53 |
|
_foreach (const _L<cse::String>, item, items) |
61 |
|
while (paths->MoveNext()) |
62 |
|
files.InsertLast(GetFile(paths->GetString(_B("path")))); |
63 |
|
|
64 |
+ |
connector->Release(connection); |
65 |
+ |
|
66 |
|
return files; |
67 |
|
} |
68 |
|
|
83 |
|
|
84 |
|
statement_ << _B("ORDER BY ") << by << _B(" LIMIT 50 OFFSET ?"); |
85 |
|
|
86 |
+ |
_R<dbi::Connection> connection(connector->Connect()); |
87 |
|
_R<dbi::Statement> statement(connection->Parse(statement_)); |
88 |
|
|
89 |
|
_foreach (const _L<cse::String>, item, items) |
98 |
|
while (items_->MoveNext()) |
99 |
|
items.InsertLast(items_->GetString(lexical_cast<cse::String>(by))); |
100 |
|
|
101 |
+ |
connector->Release(connection); |
102 |
+ |
|
103 |
|
return items; |
104 |
|
} |