<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/qsqldriver.cpp:52 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>TQSqlDriver Class</title> <style type="text/css"><!-- fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQSqlDriver Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1> <p>The TQSqlDriver class is an abstract base class for accessing SQL databases. <a href="#details">More...</a> <p><tt>#include <<a href="qsqldriver-h.html">ntqsqldriver.h</a>></tt> <p>Inherits <a href="ntqobject.html">TQObject</a>. <p><a href="qsqldriver-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li class=fn>enum <a href="#DriverFeature-enum"><b>DriverFeature</b></a> { Transactions, QuerySize, BLOB, Unicode, PreparedQueries, NamedPlaceholders, PositionalPlaceholders }</li> <li class=fn><a href="#TQSqlDriver"><b>TQSqlDriver</b></a> ( TQObject * parent = 0, const char * name = 0 )</li> <li class=fn><a href="#~TQSqlDriver"><b>~TQSqlDriver</b></a> ()</li> <li class=fn>bool <a href="#isOpen"><b>isOpen</b></a> () const</li> <li class=fn>bool <a href="#isOpenError"><b>isOpenError</b></a> () const</li> <li class=fn>virtual bool <a href="#beginTransaction"><b>beginTransaction</b></a> ()</li> <li class=fn>virtual bool <a href="#commitTransaction"><b>commitTransaction</b></a> ()</li> <li class=fn>virtual bool <a href="#rollbackTransaction"><b>rollbackTransaction</b></a> ()</li> <li class=fn>virtual TQStringList <a href="#tables"><b>tables</b></a> ( const TQString & tableType ) const</li> <li class=fn>virtual TQSqlIndex <a href="#primaryIndex"><b>primaryIndex</b></a> ( const TQString & tableName ) const</li> <li class=fn>virtual TQSqlRecord <a href="#record"><b>record</b></a> ( const TQString & tableName ) const</li> <li class=fn>virtual TQSqlRecord <a href="#record-2"><b>record</b></a> ( const TQSqlQuery & query ) const</li> <li class=fn>virtual TQSqlRecordInfo <a href="#recordInfo"><b>recordInfo</b></a> ( const TQString & tablename ) const</li> <li class=fn>virtual TQSqlRecordInfo <a href="#recordInfo-2"><b>recordInfo</b></a> ( const TQSqlQuery & query ) const</li> <li class=fn>virtual TQString <a href="#nullText"><b>nullText</b></a> () const</li> <li class=fn>virtual TQString <a href="#formatValue"><b>formatValue</b></a> ( const TQSqlField * field, bool trimStrings = FALSE ) const</li> <li class=fn>TQSqlError <a href="#lastError"><b>lastError</b></a> () const</li> <li class=fn>virtual bool <a href="#hasFeature"><b>hasFeature</b></a> ( DriverFeature f ) const = 0</li> <li class=fn>virtual bool <a href="#open"><b>open</b></a> ( const TQString & db, const TQString & user = TQString::null, const TQString & password = TQString::null, const TQString & host = TQString::null, int port = -1 ) = 0</li> <li class=fn>virtual void <a href="#close"><b>close</b></a> () = 0</li> <li class=fn>virtual TQSqlQuery <a href="#createQuery"><b>createQuery</b></a> () const = 0</li> <li class=fn>bool <a href="#open-2"><b>open</b></a> ( const TQString & db, const TQString & user, const TQString & password, const TQString & host, int port, const TQString & connOpts )</li> </ul> <h2>Protected Members</h2> <ul> <li class=fn>virtual void <a href="#setOpen"><b>setOpen</b></a> ( bool o )</li> <li class=fn>virtual void <a href="#setOpenError"><b>setOpenError</b></a> ( bool e )</li> <li class=fn>virtual void <a href="#setLastError"><b>setLastError</b></a> ( const TQSqlError & e )</li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The TQSqlDriver class is an abstract base class for accessing SQL databases. <p> <p> This class should not be used directly. Use <a href="ntqsqldatabase.html">TQSqlDatabase</a> instead. <p>See also <a href="database.html">Database Classes</a>. <hr><h2>Member Type Documentation</h2> <h3 class=fn><a name="DriverFeature-enum"></a>TQSqlDriver::DriverFeature</h3> <p> This enum contains a list of features a driver may support. Use <a href="#hasFeature">hasFeature</a>() to query whether a feature is supported or not. <ul> <li><tt>TQSqlDriver::Transactions</tt> - whether the driver supports SQL transactions <li><tt>TQSqlDriver::QuerySize</tt> - whether the database is capable of reporting the size of a query. Note that some databases do not support returning the size (i.e. number of rows returned) of a query, in which case <a href="ntqsqlquery.html#size">TQSqlQuery::size</a>() will return -1 <li><tt>TQSqlDriver::BLOB</tt> - whether the driver supports Binary Large Object fields <li><tt>TQSqlDriver::Unicode</tt> - whether the driver supports Unicode strings if the database server does <li><tt>TQSqlDriver::PreparedQueries</tt> - whether the driver supports prepared query execution <li><tt>TQSqlDriver::NamedPlaceholders</tt> - whether the driver supports usage of named placeholders <li><tt>TQSqlDriver::PositionalPlaceholders</tt> - whether the driver supports usage of positional placeholders </ul><p> More information about supported features can be found in the <a href="sql-driver.html">TQt SQL driver</a> documentation. <p> <p>See also <a href="#hasFeature">hasFeature</a>(). <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="TQSqlDriver"></a>TQSqlDriver::TQSqlDriver ( <a href="ntqobject.html">TQObject</a> * parent = 0, const char * name = 0 ) </h3> Default constructor. Creates a new driver with parent <em>parent</em>, called <em>name</em>. <p> <h3 class=fn><a name="~TQSqlDriver"></a>TQSqlDriver::~TQSqlDriver () </h3> Destroys the object and frees any allocated resources. <h3 class=fn>bool <a name="beginTransaction"></a>TQSqlDriver::beginTransaction ()<tt> [virtual]</tt> </h3> Protected function which derived classes can reimplement to begin a transaction. If successful, return TRUE, otherwise return FALSE. The default implementation returns FALSE. <p> <p>See also <a href="#commitTransaction">commitTransaction</a>() and <a href="#rollbackTransaction">rollbackTransaction</a>(). <h3 class=fn>void <a name="close"></a>TQSqlDriver::close ()<tt> [pure virtual]</tt> </h3> <p> Derived classes must reimplement this abstract virtual function in order to close the database connection. Return TRUE on success, FALSE on failure. <p> <p>See also <a href="#setOpen">setOpen</a>(). <p> <h3 class=fn>bool <a name="commitTransaction"></a>TQSqlDriver::commitTransaction ()<tt> [virtual]</tt> </h3> Protected function which derived classes can reimplement to commit a transaction. If successful, return TRUE, otherwise return FALSE. The default implementation returns FALSE. <p> <p>See also <a href="#beginTransaction">beginTransaction</a>() and <a href="#rollbackTransaction">rollbackTransaction</a>(). <h3 class=fn><a href="ntqsqlquery.html">TQSqlQuery</a> <a name="createQuery"></a>TQSqlDriver::createQuery () const<tt> [pure virtual]</tt> </h3> <p> Creates an empty SQL result on the database. Derived classes must reimplement this function and return a <a href="ntqsqlquery.html">TQSqlQuery</a> object appropriate for their database to the caller. <p> <h3 class=fn><a href="ntqstring.html">TQString</a> <a name="formatValue"></a>TQSqlDriver::formatValue ( const <a href="ntqsqlfield.html">TQSqlField</a> * field, bool trimStrings = FALSE ) const<tt> [virtual]</tt> </h3> Returns a string representation of the <em>field</em> value for the database. This is used, for example, when constructing INSERT and UPDATE statements. <p> The default implementation returns the value formatted as a string according to the following rules: <p> <ul> <p> <li> If <em>field</em> is NULL, <a href="#nullText">nullText</a>() is returned. <p> <li> If <em>field</em> is character data, the value is returned enclosed in single quotation marks, which is appropriate for many SQL databases. Any embedded single-quote characters are escaped (replaced with two single-quote characters). If <em>trimStrings</em> is TRUE (the default is FALSE), all trailing whitespace is trimmed from the field. <p> <li> If <em>field</em> is date/time data, the value is formatted in ISO format and enclosed in single quotation marks. If the date/time data is invalid, nullText() is returned. <p> <li> If <em>field</em> is bytearray data, and the driver can edit binary fields, the value is formatted as a hexadecimal string. <p> <li> For any other field type toString() will be called on its value and the result returned. <p> </ul> <p> <p>See also <a href="ntqvariant.html#toString">TQVariant::toString</a>(). <p> <h3 class=fn>bool <a name="hasFeature"></a>TQSqlDriver::hasFeature ( <a href="ntqsqldriver.html#DriverFeature-enum">DriverFeature</a> f ) const<tt> [pure virtual]</tt> </h3> <p> Returns TRUE if the driver supports feature <em>f</em>; otherwise returns FALSE. <p> Note that some databases need to be <a href="#open">open</a>() before this can be determined. <p> <p>See also <a href="#DriverFeature-enum">DriverFeature</a>. <h3 class=fn>bool <a name="isOpen"></a>TQSqlDriver::isOpen () const </h3> Returns TRUE if the database connection is open; otherwise returns FALSE. <h3 class=fn>bool <a name="isOpenError"></a>TQSqlDriver::isOpenError () const </h3> Returns TRUE if the there was an error opening the database connection; otherwise returns FALSE. <h3 class=fn><a href="ntqsqlerror.html">TQSqlError</a> <a name="lastError"></a>TQSqlDriver::lastError () const </h3> Returns a <a href="ntqsqlerror.html">TQSqlError</a> object which contains information about the last error that occurred on the database. <h3 class=fn><a href="ntqstring.html">TQString</a> <a name="nullText"></a>TQSqlDriver::nullText () const<tt> [virtual]</tt> </h3> Returns a string representation of the NULL value for the database. This is used, for example, when constructing INSERT and UPDATE statements. The default implementation returns the string "NULL". <h3 class=fn>bool <a name="open"></a>TQSqlDriver::open ( const <a href="ntqstring.html">TQString</a> & db, const <a href="ntqstring.html">TQString</a> & user = TQString::null, const <a href="ntqstring.html">TQString</a> & password = TQString::null, const <a href="ntqstring.html">TQString</a> & host = TQString::null, int port = -1 )<tt> [pure virtual]</tt> </h3> <p> Derived classes must reimplement this abstract virtual function in order to open a database connection on database <em>db</em>, using user name <em>user</em>, password <em>password</em>, host <em>host</em> and port <em>port</em>. <p> The function <em>must</em> return TRUE on success and FALSE on failure. <p> <p>See also <a href="#setOpen">setOpen</a>(). <p> <h3 class=fn>bool <a name="open-2"></a>TQSqlDriver::open ( const <a href="ntqstring.html">TQString</a> & db, const <a href="ntqstring.html">TQString</a> & user, const <a href="ntqstring.html">TQString</a> & password, const <a href="ntqstring.html">TQString</a> & host, int port, const <a href="ntqstring.html">TQString</a> & connOpts ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Open a database connection on database <em>db</em>, using user name <em>user</em>, password <em>password</em>, host <em>host</em>, port <em>port</em> and connection options <em>connOpts</em>. <p> Returns TRUE on success and FALSE on failure. <p> <p>See also <a href="#setOpen">setOpen</a>(). <h3 class=fn><a href="ntqsqlindex.html">TQSqlIndex</a> <a name="primaryIndex"></a>TQSqlDriver::primaryIndex ( const <a href="ntqstring.html">TQString</a> & tableName ) const<tt> [virtual]</tt> </h3> Returns the primary index for table <em>tableName</em>. Returns an empty <a href="ntqsqlindex.html">TQSqlIndex</a> if the table doesn't have a primary index. The default implementation returns an empty index. <h3 class=fn><a href="ntqsqlrecord.html">TQSqlRecord</a> <a name="record"></a>TQSqlDriver::record ( const <a href="ntqstring.html">TQString</a> & tableName ) const<tt> [virtual]</tt> </h3> Returns a <a href="ntqsqlrecord.html">TQSqlRecord</a> populated with the names of the fields in table <em>tableName</em>. If no such table exists, an empty record is returned. The default implementation returns an empty record. <h3 class=fn><a href="ntqsqlrecord.html">TQSqlRecord</a> <a name="record-2"></a>TQSqlDriver::record ( const <a href="ntqsqlquery.html">TQSqlQuery</a> & query ) const<tt> [virtual]</tt> </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns a <a href="ntqsqlrecord.html">TQSqlRecord</a> populated with the names of the fields in the SQL <em>query</em>. The default implementation returns an empty record. <h3 class=fn><a href="qsqlrecordinfo.html">TQSqlRecordInfo</a> <a name="recordInfo"></a>TQSqlDriver::recordInfo ( const <a href="ntqstring.html">TQString</a> & tablename ) const<tt> [virtual]</tt> </h3> Returns a <a href="qsqlrecordinfo.html">TQSqlRecordInfo</a> object with meta data about the table <em>tablename</em>. <h3 class=fn><a href="qsqlrecordinfo.html">TQSqlRecordInfo</a> <a name="recordInfo-2"></a>TQSqlDriver::recordInfo ( const <a href="ntqsqlquery.html">TQSqlQuery</a> & query ) const<tt> [virtual]</tt> </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns a <a href="qsqlrecordinfo.html">TQSqlRecordInfo</a> object with meta data for the <a href="ntqsqlquery.html">TQSqlQuery</a> <em>query</em>. Note that this overloaded function may return less information than the <a href="#recordInfo">recordInfo</a>() function which takes the name of a table as parameter. <h3 class=fn>bool <a name="rollbackTransaction"></a>TQSqlDriver::rollbackTransaction ()<tt> [virtual]</tt> </h3> Protected function which derived classes can reimplement to rollback a transaction. If successful, return TRUE, otherwise return FALSE. The default implementation returns FALSE. <p> <p>See also <a href="#beginTransaction">beginTransaction</a>() and <a href="#commitTransaction">commitTransaction</a>(). <h3 class=fn>void <a name="setLastError"></a>TQSqlDriver::setLastError ( const <a href="ntqsqlerror.html">TQSqlError</a> & e )<tt> [virtual protected]</tt> </h3> Protected function which allows derived classes to set the value of the last error, <em>e</em>, that occurred on the database. <p> <p>See also <a href="#lastError">lastError</a>(). <h3 class=fn>void <a name="setOpen"></a>TQSqlDriver::setOpen ( bool o )<tt> [virtual protected]</tt> </h3> Protected function which sets the open state of the database to <em>o</em>. Derived classes can use this function to report the status of <a href="#open">open</a>(). <p> <p>See also <a href="#open">open</a>() and <a href="#setOpenError">setOpenError</a>(). <h3 class=fn>void <a name="setOpenError"></a>TQSqlDriver::setOpenError ( bool e )<tt> [virtual protected]</tt> </h3> Protected function which sets the open error state of the database to <em>e</em>. Derived classes can use this function to report the status of <a href="#open">open</a>(). Note that if <em>e</em> is TRUE the open state of the database is set to closed (i.e. <a href="#isOpen">isOpen</a>() returns FALSE). <p> <p>See also <a href="#open">open</a>(). <h3 class=fn><a href="ntqstringlist.html">TQStringList</a> <a name="tables"></a>TQSqlDriver::tables ( const <a href="ntqstring.html">TQString</a> & tableType ) const<tt> [virtual]</tt> </h3> Returns a list of tables in the database. The default implementation returns an empty list. <p> The <em>tableType</em> argument describes what types of tables should be returned. Due to binary compatibility, the string contains the value of the enum TQSql::TableTypes as text. An empty string should be treated as TQSql::Tables for downward compatibility. <p> <p>See also <a href="ntqsql.html#TableType-enum">TQSql::TableType</a>. <!-- eof --> <hr><p> This file is part of the <a href="index.html">TQt toolkit</a>. Copyright © 1995-2007 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2007 <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> <td align=right><div align=right>TQt 3.3.8</div> </table></div></address></body> </html>