mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
const correctness
This commit is contained in:
parent
1495b263d9
commit
b97162ba5d
2 changed files with 13 additions and 14 deletions
|
@ -26,6 +26,8 @@ Core::Db::Connection::Connection( MySqlBase * pBase,
|
|||
m_pBase( pBase )
|
||||
{
|
||||
m_pRawCon = mysql_init( nullptr );
|
||||
// Different mysql versions support different options, for now whatever was unsupporter here was commented out
|
||||
// but left there.
|
||||
for( auto entry : options )
|
||||
{
|
||||
switch( entry.first )
|
||||
|
@ -138,25 +140,26 @@ void Core::Db::Connection::close()
|
|||
m_bConnected = false;
|
||||
}
|
||||
|
||||
bool Core::Db::Connection::isClosed()
|
||||
bool Core::Db::Connection::isClosed() const
|
||||
{
|
||||
return !m_bConnected;
|
||||
}
|
||||
|
||||
Core::Db::MySqlBase* Core::Db::Connection::getMySqlBase()
|
||||
Core::Db::MySqlBase* Core::Db::Connection::getMySqlBase() const
|
||||
{
|
||||
return m_pBase;
|
||||
}
|
||||
|
||||
void Core::Db::Connection::setAutoCommit( bool autoCommit )
|
||||
{
|
||||
my_bool b = autoCommit == true ? 1 : 0;
|
||||
auto b = static_cast< my_bool >( autoCommit == true ? 1 : 0 );
|
||||
if( mysql_autocommit( m_pRawCon, b ) != 0 )
|
||||
throw std::runtime_error( "Connection::setAutoCommit failed!" );
|
||||
}
|
||||
|
||||
bool Core::Db::Connection::getAutoCommit()
|
||||
{
|
||||
// TODO: should be replaced with wrapped sql query function once available
|
||||
std::string query("SELECT @@autocommit");
|
||||
auto res = mysql_real_query( m_pRawCon, query.c_str(), query.length() );
|
||||
|
||||
|
@ -168,6 +171,6 @@ bool Core::Db::Connection::getAutoCommit()
|
|||
|
||||
uint32_t ac = atoi( row[0] );
|
||||
|
||||
return ac == 0 ? false : true;
|
||||
return ac != 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,20 +34,18 @@ namespace Db
|
|||
virtual ~Connection();
|
||||
|
||||
void close();
|
||||
bool isClosed();
|
||||
bool isClosed() const;
|
||||
|
||||
void setOption( enum mysql_option option, const void *arg );
|
||||
void setOption( enum mysql_option option, uint32_t arg );
|
||||
void setOption( enum mysql_option option, const std::string& arg );
|
||||
|
||||
MySqlBase *getMySqlBase();
|
||||
MySqlBase *getMySqlBase() const;
|
||||
|
||||
void setAutoCommit( bool autoCommit );
|
||||
|
||||
//// implemented up to this point
|
||||
|
||||
bool getAutoCommit();
|
||||
|
||||
//// implemented up to this point
|
||||
|
||||
void beginTransaction();
|
||||
void commitTransaction();
|
||||
|
@ -57,8 +55,6 @@ namespace Db
|
|||
|
||||
std::string escapeString( const std::string& );
|
||||
|
||||
|
||||
|
||||
std::string getSchema();
|
||||
void setSchema( const std::string& catalog );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue