m_pDS and m_pDB in VideoDatabase
#1
I'm working on my own feature request to hide unavailable library items. I need to add methods to VideoDatabase that gets some fields from a new table. I've looked at similar methods in VideoDatabase.cpp and many of them start with this

Code:
if (!m_pDB.get() || !m_pDS.get())
      return false;
and then the query
Code:
sql = PrepareSQL("SELECT * FROM path);
m_pDS->query(sql.c_str());
    while (!m_pDS->eof())
    {
       ... Do stuff with the retrieved data ...
    }
But this is not the case with all methods. Most methods also end with
Code:
m_pDS->close();
but not all.

The problem is that I get an exception if I just add this to my method.

I would be very happy if someone could explain what m_pDS and m_pDB is, and how I should use them to build my method.
Reply
#2
Ok, I forgot to open the database so that's why it didn't work. I would still like to know what is going on with m_pDS, m_pDS2, and m_pDB
Reply
#3
m_pDB is the database connection.

m_pDS and m_pDS2 are two dataset handles (= results from queries) from this db. since creating a database connection, as well as creating a dataset handle, is time consuming, members are kept which are reused in the various queries / member functions. there are no obvious rules as to which is used where. preliminary m_pDS is used, but sometimes m_pDS2 needs to be used due to recursive db function calls.

as for missing Close() calls, that's usually just an oversight. the only effect is potentially some more memory usage until the dataset is reused.
Reply
#4
Thank you!

We should add your explanation as comments in the declaration of m_pDS and m_pDB.

Is there a reason why some methods use
Code:
if (!m_pDB.get() || !m_pDS.get()) return false
and others use
Code:
if (NULL == m_pDB.get()) return;
if (NULL == m_pDS.get()) return;
?
Reply
#5
The meaning is identical ... (beside that one function returns a bool as it seems).
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#6
ok, thanks
Reply

Logout Mark Read Team Forum Stats Members Help
m_pDS and m_pDB in VideoDatabase0