Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
1d34596e
Commit
1d34596e
authored
May 11, 2014
by
Hugo Beauzée-Luyssen
Browse files
Create tables when initializing
parent
4f1c8fa9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/MediaLibrary.cpp
View file @
1d34596e
#include "MediaLibrary.h"
#include "SqliteTools.h"
#include "File.h"
#include "Label.h"
#include "Album.h"
#include "AlbumTrack.h"
#include "Show.h"
#include "ShowEpisode.h"
MediaLibrary
::
MediaLibrary
()
{
...
...
@@ -7,9 +14,19 @@ MediaLibrary::MediaLibrary()
bool
MediaLibrary
::
initialize
(
const
std
::
string
&
dbPath
)
{
int
res
=
sqlite3_open
(
dbPath
.
c_str
(),
&
m_dbConnection
);
//FIXME:
// PRAGMA foreign_keys = ON;
return
res
==
SQLITE_OK
;
if
(
res
!=
SQLITE_OK
)
return
false
;
sqlite3_stmt
*
stmt
;
sqlite3_prepare_v2
(
m_dbConnection
,
"PRAGMA foreign_keys = ON"
,
-
1
,
&
stmt
,
NULL
);
if
(
sqlite3_step
(
stmt
)
!=
SQLITE_DONE
)
return
false
;
return
(
File
::
createTable
(
m_dbConnection
)
&&
Label
::
createTable
(
m_dbConnection
)
&&
Album
::
createTable
(
m_dbConnection
)
&&
AlbumTrack
::
createTable
(
m_dbConnection
)
&&
Show
::
createTable
(
m_dbConnection
)
&&
ShowEpisode
::
createTable
(
m_dbConnection
)
);
}
...
...
@@ -17,8 +34,8 @@ const std::vector<IFile*>&MediaLibrary::files()
{
if
(
m_files
==
NULL
)
{
m_files
=
new
std
::
vector
<
IFile
*>
()
;
// magic
const
char
*
req
=
"SELECT * FROM Files"
;
SqliteTools
::
fetchAll
<
File
>
(
m_dbConnection
,
req
,
0
,
m_files
);
}
return
*
m_files
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment