См. документацию.00001 #ifndef         __DATABASE_CPP__
00002 #define         __DATABASE_CPP__
00003 
00004 #include        <db/database.h>
00005 
00006 namespace       nitro{
00007 
00008          void                              Database::Connect( const std::string & theConnectionString )
00009         {
00010                 try
00011                 {
00012                         Connect( theConnectionString.c_str() );
00013                 }
00014                 catch( nitro::exception e )
00015                 {
00016                         throw( nitro::exception( std::string( "Database::Connect( const std::string & theConnectionString )::" ) + e.what() , e.code() ) );
00017                 }
00018                 catch( ... )
00019                 {
00020                         throw( nitro::exception( std::string( "Database::Connect( const std::string & theConnectionString )::An error occured" ) , 0 ) );
00021                 }
00022         }
00023 
00024          void                              Database::Query( const std::string & theQueryString )
00025         {
00026                 try
00027                 {
00028                         Query( theQueryString.c_str() );
00029                 }
00030                 catch( nitro::exception e )
00031                 {
00032                         throw( nitro::exception( std::string( "Database::Query( const std::string & theQueryString )::" ) + e.what() , e.code() ) );
00033                 }
00034                 catch( ... )
00035                 {
00036                         throw( nitro::exception( std::string( "Database::Query( const std::string & theQueryString )::An error occured" ) , 0 ) );
00037                 }
00038         }
00039 
00040         void                                                    Database::Select( const std::string & What , const std::string & Tables , const std::string & Condition  )
00041         {
00042                 try
00043                 {
00044                         ClearResult();
00045 
00046                         Query( ( std::string( "SELECT " ) + What + " FROM " + Tables + " WHERE " + Condition ).c_str() );
00047                 }
00048                 catch( nitro::exception e )
00049                 {
00050                         throw( nitro::exception( std::string( "Database::Select( const std::string & What , const std::string & Tables , const std::string & Condition /* = 1 = 1 */ )::" ) + e.what() , e.code() ) );
00051                 }
00052                 catch( ... )
00053                 {
00054                         throw( nitro::exception( std::string( "Database::Select( const std::string & What , const std::string & Tables , const std::string & Condition /* = 1 = 1 */ )::An error occured" ) , 0 ) );
00055                 }
00056         }
00057 
00058          void                              Database::Insert( const std::string & Table , const std::string & Fields , const std::string & Values )
00059         {
00060                 try
00061                 {
00062                         Query( ( std::string( "INSERT INTO " ) + Table + " ( " + Fields + " ) VALUES ( " + Values + " )" ).c_str() );
00063                 }
00064                 catch( nitro::exception e )
00065                 {
00066                         throw( nitro::exception( std::string( "Database::Insert( const std::string & Table , const std::string & Fields , const std::string & Values )::" ) + e.what() , e.code() ) );
00067                 }
00068                 catch( ... )
00069                 {
00070                         throw( nitro::exception( std::string( "Database::Insert( const std::string & Table , const std::string & Fields , const std::string & Values )::An error occured" ) , 0 ) );
00071                 }
00072         }
00073 
00074          void                              Database::Delete( const std::string & Table , const std::string & Condition  )
00075         {
00076                 try
00077                 {
00078                         Query( ( std::string( "DELETE FROM " ) + Table + " WHERE " + Condition ).c_str() );
00079                 }
00080                 catch( nitro::exception e )
00081                 {
00082                         throw( nitro::exception( std::string( "Database::Delete( const std::string & Table , const std::string & Condition )::" ) + e.what() , e.code() ) );
00083                 }
00084                 catch( ... )
00085                 {
00086                         throw( nitro::exception( std::string( "Database::Delete( const std::string & Table , const std::string & Condition )::An error occured" ) , 0 ) );
00087                 }
00088         }
00089 
00090          Database::~Database()
00091         {
00092                 try
00093                 {
00094                 }
00095                 catch( ... )
00096                 {
00097                 }
00098         }
00099 
00100 };
00101 
00102 #endif