You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
261 lines
13 KiB
261 lines
13 KiB
<!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/tqsqlresult.cpp:54 -->
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>TQSqlResult 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>TQSqlResult Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>
|
|
|
|
<p>The TQSqlResult class provides an abstract interface for
|
|
accessing data from SQL databases.
|
|
<a href="#details">More...</a>
|
|
<p><tt>#include <<a href="tqsqlresult-h.html">tqsqlresult.h</a>></tt>
|
|
<p><a href="tqsqlresult-members.html">List of all member functions.</a>
|
|
<h2>Public Members</h2>
|
|
<ul>
|
|
<li class=fn>virtual <a href="#~TQSqlResult"><b>~TQSqlResult</b></a> ()</li>
|
|
</ul>
|
|
<h2>Protected Members</h2>
|
|
<ul>
|
|
<li class=fn><a href="#TQSqlResult"><b>TQSqlResult</b></a> ( const TQSqlDriver * db )</li>
|
|
<li class=fn>int <a href="#at"><b>at</b></a> () const</li>
|
|
<li class=fn>TQString <a href="#lastQuery"><b>lastQuery</b></a> () const</li>
|
|
<li class=fn>TQSqlError <a href="#lastError"><b>lastError</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isActive"><b>isActive</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isSelect"><b>isSelect</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isForwardOnly"><b>isForwardOnly</b></a> () const</li>
|
|
<li class=fn>const TQSqlDriver * <a href="#driver"><b>driver</b></a> () const</li>
|
|
<li class=fn>virtual void <a href="#setAt"><b>setAt</b></a> ( int at )</li>
|
|
<li class=fn>virtual void <a href="#setActive"><b>setActive</b></a> ( bool a )</li>
|
|
<li class=fn>virtual void <a href="#setLastError"><b>setLastError</b></a> ( const TQSqlError & e )</li>
|
|
<li class=fn>virtual void <a href="#setQuery"><b>setQuery</b></a> ( const TQString & query )</li>
|
|
<li class=fn>virtual void <a href="#setSelect"><b>setSelect</b></a> ( bool s )</li>
|
|
<li class=fn>virtual void <a href="#setForwardOnly"><b>setForwardOnly</b></a> ( bool forward )</li>
|
|
<li class=fn>virtual TQVariant <a href="#data"><b>data</b></a> ( int i ) = 0</li>
|
|
<li class=fn>virtual bool <a href="#isNull"><b>isNull</b></a> ( int i ) = 0</li>
|
|
<li class=fn>virtual bool <a href="#reset"><b>reset</b></a> ( const TQString & query ) = 0</li>
|
|
<li class=fn>virtual bool <a href="#fetch"><b>fetch</b></a> ( int i ) = 0</li>
|
|
<li class=fn>virtual bool <a href="#fetchNext"><b>fetchNext</b></a> ()</li>
|
|
<li class=fn>virtual bool <a href="#fetchPrev"><b>fetchPrev</b></a> ()</li>
|
|
<li class=fn>virtual bool <a href="#fetchFirst"><b>fetchFirst</b></a> () = 0</li>
|
|
<li class=fn>virtual bool <a href="#fetchLast"><b>fetchLast</b></a> () = 0</li>
|
|
<li class=fn>virtual int <a href="#size"><b>size</b></a> () = 0</li>
|
|
<li class=fn>virtual int <a href="#numRowsAffected"><b>numRowsAffected</b></a> () = 0</li>
|
|
</ul>
|
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
|
|
|
|
|
The TQSqlResult class provides an abstract interface for
|
|
accessing data from SQL databases.
|
|
<p>
|
|
|
|
<p> Normally you would use <a href="tqsqlquery.html">TQSqlQuery</a> instead of TQSqlResult since TQSqlQuery
|
|
provides a generic wrapper for database-specific implementations of
|
|
TQSqlResult.
|
|
<p> <p>See also <a href="tqsql.html">TQSql</a> and <a href="database.html">Database Classes</a>.
|
|
|
|
<hr><h2>Member Function Documentation</h2>
|
|
<h3 class=fn><a name="TQSqlResult"></a>TQSqlResult::TQSqlResult ( const <a href="tqsqldriver.html">TQSqlDriver</a> * db )<tt> [protected]</tt>
|
|
</h3>
|
|
Protected constructor which creates a TQSqlResult using database <em>db</em>. The object is initialized to an inactive state.
|
|
|
|
<h3 class=fn><a name="~TQSqlResult"></a>TQSqlResult::~TQSqlResult ()<tt> [virtual]</tt>
|
|
</h3>
|
|
Destroys the object and frees any allocated resources.
|
|
|
|
<h3 class=fn>int <a name="at"></a>TQSqlResult::at () const<tt> [protected]</tt>
|
|
</h3>
|
|
Returns the current (zero-based) position of the result.
|
|
|
|
<h3 class=fn><a href="ntqvariant.html">TQVariant</a> <a name="data"></a>TQSqlResult::data ( int i )<tt> [pure virtual protected]</tt>
|
|
</h3>
|
|
|
|
<p> Returns the data for field <em>i</em> (zero-based) as a <a href="ntqvariant.html">TQVariant</a>. This
|
|
function is only called if the result is in an active state and is
|
|
positioned on a valid record and <em>i</em> is non-negative.
|
|
Derived classes must reimplement this function and return the value
|
|
of field <em>i</em>, or TQVariant() if it cannot be determined.
|
|
|
|
<h3 class=fn>const <a href="tqsqldriver.html">TQSqlDriver</a> * <a name="driver"></a>TQSqlResult::driver () const<tt> [protected]</tt>
|
|
</h3>
|
|
Returns the driver associated with the result.
|
|
|
|
<h3 class=fn>bool <a name="fetch"></a>TQSqlResult::fetch ( int i )<tt> [pure virtual protected]</tt>
|
|
</h3>
|
|
|
|
<p> Positions the result to an arbitrary (zero-based) index <em>i</em>. This
|
|
function is only called if the result is in an active state. Derived
|
|
classes must reimplement this function and position the result to the
|
|
index <em>i</em>, and call <a href="#setAt">setAt</a>() with an appropriate value. Return TRUE
|
|
to indicate success, or FALSE to signify failure.
|
|
|
|
<h3 class=fn>bool <a name="fetchFirst"></a>TQSqlResult::fetchFirst ()<tt> [pure virtual protected]</tt>
|
|
</h3>
|
|
|
|
<p> Positions the result to the first record in the result. This
|
|
function is only called if the result is in an active state.
|
|
Derived classes must reimplement this function and position the result
|
|
to the first record, and call <a href="#setAt">setAt</a>() with an appropriate value.
|
|
Return TRUE to indicate success, or FALSE to signify failure.
|
|
|
|
<h3 class=fn>bool <a name="fetchLast"></a>TQSqlResult::fetchLast ()<tt> [pure virtual protected]</tt>
|
|
</h3>
|
|
|
|
<p> Positions the result to the last record in the result. This
|
|
function is only called if the result is in an active state.
|
|
Derived classes must reimplement this function and position the result
|
|
to the last record, and call <a href="#setAt">setAt</a>() with an appropriate value.
|
|
Return TRUE to indicate success, or FALSE to signify failure.
|
|
|
|
<h3 class=fn>bool <a name="fetchNext"></a>TQSqlResult::fetchNext ()<tt> [virtual protected]</tt>
|
|
</h3>
|
|
Positions the result to the next available record in the result.
|
|
This function is only called if the result is in an active state.
|
|
The default implementation calls <a href="#fetch">fetch</a>() with the next index.
|
|
Derived classes can reimplement this function and position the result
|
|
to the next record in some other way, and call <a href="#setAt">setAt</a>() with an
|
|
appropriate value. Return TRUE to indicate success, or FALSE to
|
|
signify failure.
|
|
|
|
<h3 class=fn>bool <a name="fetchPrev"></a>TQSqlResult::fetchPrev ()<tt> [virtual protected]</tt>
|
|
</h3>
|
|
Positions the result to the previous available record in the
|
|
result. This function is only called if the result is in an active
|
|
state. The default implementation calls <a href="#fetch">fetch</a>() with the previous
|
|
index. Derived classes can reimplement this function and position the
|
|
result to the next record in some other way, and call <a href="#setAt">setAt</a>() with
|
|
an appropriate value. Return TRUE to indicate success, or FALSE to
|
|
signify failure.
|
|
|
|
<h3 class=fn>bool <a name="isActive"></a>TQSqlResult::isActive () const<tt> [protected]</tt>
|
|
</h3>
|
|
Returns TRUE if the result has records to be retrieved; otherwise
|
|
returns FALSE.
|
|
|
|
<h3 class=fn>bool <a name="isForwardOnly"></a>TQSqlResult::isForwardOnly () const<tt> [protected]</tt>
|
|
</h3>
|
|
Returns TRUE if you can only scroll forward through a result set;
|
|
otherwise returns FALSE.
|
|
|
|
<h3 class=fn>bool <a name="isNull"></a>TQSqlResult::isNull ( int i )<tt> [pure virtual protected]</tt>
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the field at position <em>i</em> is NULL; otherwise
|
|
returns FALSE.
|
|
|
|
<h3 class=fn>bool <a name="isSelect"></a>TQSqlResult::isSelect () const<tt> [protected]</tt>
|
|
</h3>
|
|
Returns TRUE if the current result is from a SELECT statement;
|
|
otherwise returns FALSE.
|
|
|
|
<h3 class=fn>bool <a name="isValid"></a>TQSqlResult::isValid () const<tt> [protected]</tt>
|
|
</h3>
|
|
Returns TRUE if the result is positioned on a valid record (that
|
|
is, the result is not positioned before the first or after the
|
|
last record); otherwise returns FALSE.
|
|
|
|
<h3 class=fn><a href="tqsqlerror.html">TQSqlError</a> <a name="lastError"></a>TQSqlResult::lastError () const<tt> [protected]</tt>
|
|
</h3>
|
|
Returns the last error associated with the result.
|
|
|
|
<h3 class=fn><a href="tqstring.html">TQString</a> <a name="lastQuery"></a>TQSqlResult::lastQuery () const<tt> [protected]</tt>
|
|
</h3>
|
|
Returns the current SQL query text, or <a href="tqstring.html#TQString-null">TQString::null</a> if there is none.
|
|
|
|
<h3 class=fn>int <a name="numRowsAffected"></a>TQSqlResult::numRowsAffected ()<tt> [pure virtual protected]</tt>
|
|
</h3>
|
|
|
|
<p> Returns the number of rows affected by the last query executed.
|
|
|
|
<h3 class=fn>bool <a name="reset"></a>TQSqlResult::reset ( const <a href="tqstring.html">TQString</a> & query )<tt> [pure virtual protected]</tt>
|
|
</h3>
|
|
|
|
<p> Sets the result to use the SQL statement <em>query</em> for subsequent
|
|
data retrieval. Derived classes must reimplement this function and
|
|
apply the <em>query</em> to the database. This function is called only
|
|
after the result is set to an inactive state and is positioned
|
|
before the first record of the new result. Derived classes should
|
|
return TRUE if the query was successful and ready to be used,
|
|
or FALSE otherwise.
|
|
|
|
<h3 class=fn>void <a name="setActive"></a>TQSqlResult::setActive ( bool a )<tt> [virtual protected]</tt>
|
|
</h3>
|
|
Protected function provided for derived classes to set the
|
|
internal active state to the value of <em>a</em>.
|
|
<p> <p>See also <a href="#isActive">isActive</a>().
|
|
|
|
<h3 class=fn>void <a name="setAt"></a>TQSqlResult::setAt ( int at )<tt> [virtual protected]</tt>
|
|
</h3>
|
|
Protected function provided for derived classes to set the
|
|
internal (zero-based) result index to <em>at</em>.
|
|
<p> <p>See also <a href="#at">at</a>().
|
|
|
|
<h3 class=fn>void <a name="setForwardOnly"></a>TQSqlResult::setForwardOnly ( bool forward )<tt> [virtual protected]</tt>
|
|
</h3>
|
|
Sets forward only mode to <em>forward</em>. If forward is TRUE only
|
|
<a href="#fetchNext">fetchNext</a>() is allowed for navigating the results. Forward only
|
|
mode needs far less memory since results do not have to be cached.
|
|
forward only mode is off by default.
|
|
<p> <p>See also <a href="#fetchNext">fetchNext</a>().
|
|
|
|
<h3 class=fn>void <a name="setLastError"></a>TQSqlResult::setLastError ( const <a href="tqsqlerror.html">TQSqlError</a> & e )<tt> [virtual protected]</tt>
|
|
</h3>
|
|
Protected function provided for derived classes to set the last
|
|
error to the value of <em>e</em>.
|
|
<p> <p>See also <a href="#lastError">lastError</a>().
|
|
|
|
<h3 class=fn>void <a name="setQuery"></a>TQSqlResult::setQuery ( const <a href="tqstring.html">TQString</a> & query )<tt> [virtual protected]</tt>
|
|
</h3>
|
|
Sets the current query for the result to <em>query</em>. The result must
|
|
be <a href="#reset">reset</a>() in order to execute the query on the database.
|
|
|
|
<h3 class=fn>void <a name="setSelect"></a>TQSqlResult::setSelect ( bool s )<tt> [virtual protected]</tt>
|
|
</h3>
|
|
Protected function provided for derived classes to indicate
|
|
whether or not the current statement is a SQL SELECT statement.
|
|
The <em>s</em> parameter should be TRUE if the statement is a SELECT
|
|
statement, or FALSE otherwise.
|
|
|
|
<h3 class=fn>int <a name="size"></a>TQSqlResult::size ()<tt> [pure virtual protected]</tt>
|
|
</h3>
|
|
|
|
<p> Returns the size of the result or -1 if it cannot be determined.
|
|
|
|
<!-- 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>
|