source: trunk/doc/html/qsqlresult.html@ 208

Last change on this file since 208 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 12.9 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/qsqlresult.cpp:54 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QSqlResult Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QSqlResult Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>
33
34<p>The QSqlResult class provides an abstract interface for
35accessing data from SQL databases.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qsqlresult-h.html">qsqlresult.h</a>&gt;</tt>
38<p><a href="qsqlresult-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn>virtual <a href="#~QSqlResult"><b>~QSqlResult</b></a> ()</li>
42</ul>
43<h2>Protected Members</h2>
44<ul>
45<li class=fn><a href="#QSqlResult"><b>QSqlResult</b></a> ( const&nbsp;QSqlDriver&nbsp;*&nbsp;db )</li>
46<li class=fn>int <a href="#at"><b>at</b></a> () const</li>
47<li class=fn>QString <a href="#lastQuery"><b>lastQuery</b></a> () const</li>
48<li class=fn>QSqlError <a href="#lastError"><b>lastError</b></a> () const</li>
49<li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li>
50<li class=fn>bool <a href="#isActive"><b>isActive</b></a> () const</li>
51<li class=fn>bool <a href="#isSelect"><b>isSelect</b></a> () const</li>
52<li class=fn>bool <a href="#isForwardOnly"><b>isForwardOnly</b></a> () const</li>
53<li class=fn>const QSqlDriver * <a href="#driver"><b>driver</b></a> () const</li>
54<li class=fn>virtual void <a href="#setAt"><b>setAt</b></a> ( int&nbsp;at )</li>
55<li class=fn>virtual void <a href="#setActive"><b>setActive</b></a> ( bool&nbsp;a )</li>
56<li class=fn>virtual void <a href="#setLastError"><b>setLastError</b></a> ( const&nbsp;QSqlError&nbsp;&amp;&nbsp;e )</li>
57<li class=fn>virtual void <a href="#setQuery"><b>setQuery</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;query )</li>
58<li class=fn>virtual void <a href="#setSelect"><b>setSelect</b></a> ( bool&nbsp;s )</li>
59<li class=fn>virtual void <a href="#setForwardOnly"><b>setForwardOnly</b></a> ( bool&nbsp;forward )</li>
60<li class=fn>virtual QVariant <a href="#data"><b>data</b></a> ( int&nbsp;i ) = 0</li>
61<li class=fn>virtual bool <a href="#isNull"><b>isNull</b></a> ( int&nbsp;i ) = 0</li>
62<li class=fn>virtual bool <a href="#reset"><b>reset</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;query ) = 0</li>
63<li class=fn>virtual bool <a href="#fetch"><b>fetch</b></a> ( int&nbsp;i ) = 0</li>
64<li class=fn>virtual bool <a href="#fetchNext"><b>fetchNext</b></a> ()</li>
65<li class=fn>virtual bool <a href="#fetchPrev"><b>fetchPrev</b></a> ()</li>
66<li class=fn>virtual bool <a href="#fetchFirst"><b>fetchFirst</b></a> () = 0</li>
67<li class=fn>virtual bool <a href="#fetchLast"><b>fetchLast</b></a> () = 0</li>
68<li class=fn>virtual int <a href="#size"><b>size</b></a> () = 0</li>
69<li class=fn>virtual int <a href="#numRowsAffected"><b>numRowsAffected</b></a> () = 0</li>
70</ul>
71<hr><a name="details"></a><h2>Detailed Description</h2>
72
73
74The QSqlResult class provides an abstract interface for
75accessing data from SQL databases.
76<p>
77
78<p> Normally you would use <a href="qsqlquery.html">QSqlQuery</a> instead of QSqlResult since QSqlQuery
79provides a generic wrapper for database-specific implementations of
80QSqlResult.
81<p> <p>See also <a href="qsql.html">QSql</a> and <a href="database.html">Database Classes</a>.
82
83<hr><h2>Member Function Documentation</h2>
84<h3 class=fn><a name="QSqlResult"></a>QSqlResult::QSqlResult ( const&nbsp;<a href="qsqldriver.html">QSqlDriver</a>&nbsp;*&nbsp;db )<tt> [protected]</tt>
85</h3>
86Protected constructor which creates a QSqlResult using database <em>db</em>. The object is initialized to an inactive state.
87
88<h3 class=fn><a name="~QSqlResult"></a>QSqlResult::~QSqlResult ()<tt> [virtual]</tt>
89</h3>
90Destroys the object and frees any allocated resources.
91
92<h3 class=fn>int <a name="at"></a>QSqlResult::at () const<tt> [protected]</tt>
93</h3>
94Returns the current (zero-based) position of the result.
95
96<h3 class=fn><a href="qvariant.html">QVariant</a> <a name="data"></a>QSqlResult::data ( int&nbsp;i )<tt> [pure virtual protected]</tt>
97</h3>
98
99<p> Returns the data for field <em>i</em> (zero-based) as a <a href="qvariant.html">QVariant</a>. This
100function is only called if the result is in an active state and is
101positioned on a valid record and <em>i</em> is non-negative.
102Derived classes must reimplement this function and return the value
103of field <em>i</em>, or QVariant() if it cannot be determined.
104
105<h3 class=fn>const&nbsp;<a href="qsqldriver.html">QSqlDriver</a>&nbsp;* <a name="driver"></a>QSqlResult::driver () const<tt> [protected]</tt>
106</h3>
107Returns the driver associated with the result.
108
109<h3 class=fn>bool <a name="fetch"></a>QSqlResult::fetch ( int&nbsp;i )<tt> [pure virtual protected]</tt>
110</h3>
111
112<p> Positions the result to an arbitrary (zero-based) index <em>i</em>. This
113function is only called if the result is in an active state. Derived
114classes must reimplement this function and position the result to the
115index <em>i</em>, and call <a href="#setAt">setAt</a>() with an appropriate value. Return TRUE
116to indicate success, or FALSE to signify failure.
117
118<h3 class=fn>bool <a name="fetchFirst"></a>QSqlResult::fetchFirst ()<tt> [pure virtual protected]</tt>
119</h3>
120
121<p> Positions the result to the first record in the result. This
122function is only called if the result is in an active state.
123Derived classes must reimplement this function and position the result
124to the first record, and call <a href="#setAt">setAt</a>() with an appropriate value.
125Return TRUE to indicate success, or FALSE to signify failure.
126
127<h3 class=fn>bool <a name="fetchLast"></a>QSqlResult::fetchLast ()<tt> [pure virtual protected]</tt>
128</h3>
129
130<p> Positions the result to the last record in the result. This
131function is only called if the result is in an active state.
132Derived classes must reimplement this function and position the result
133to the last record, and call <a href="#setAt">setAt</a>() with an appropriate value.
134Return TRUE to indicate success, or FALSE to signify failure.
135
136<h3 class=fn>bool <a name="fetchNext"></a>QSqlResult::fetchNext ()<tt> [virtual protected]</tt>
137</h3>
138Positions the result to the next available record in the result.
139This function is only called if the result is in an active state.
140The default implementation calls <a href="#fetch">fetch</a>() with the next index.
141Derived classes can reimplement this function and position the result
142to the next record in some other way, and call <a href="#setAt">setAt</a>() with an
143appropriate value. Return TRUE to indicate success, or FALSE to
144signify failure.
145
146<h3 class=fn>bool <a name="fetchPrev"></a>QSqlResult::fetchPrev ()<tt> [virtual protected]</tt>
147</h3>
148Positions the result to the previous available record in the
149result. This function is only called if the result is in an active
150state. The default implementation calls <a href="#fetch">fetch</a>() with the previous
151index. Derived classes can reimplement this function and position the
152result to the next record in some other way, and call <a href="#setAt">setAt</a>() with
153an appropriate value. Return TRUE to indicate success, or FALSE to
154signify failure.
155
156<h3 class=fn>bool <a name="isActive"></a>QSqlResult::isActive () const<tt> [protected]</tt>
157</h3>
158Returns TRUE if the result has records to be retrieved; otherwise
159returns FALSE.
160
161<h3 class=fn>bool <a name="isForwardOnly"></a>QSqlResult::isForwardOnly () const<tt> [protected]</tt>
162</h3>
163Returns TRUE if you can only scroll forward through a result set;
164otherwise returns FALSE.
165
166<h3 class=fn>bool <a name="isNull"></a>QSqlResult::isNull ( int&nbsp;i )<tt> [pure virtual protected]</tt>
167</h3>
168
169<p> Returns TRUE if the field at position <em>i</em> is NULL; otherwise
170returns FALSE.
171
172<h3 class=fn>bool <a name="isSelect"></a>QSqlResult::isSelect () const<tt> [protected]</tt>
173</h3>
174Returns TRUE if the current result is from a SELECT statement;
175otherwise returns FALSE.
176
177<h3 class=fn>bool <a name="isValid"></a>QSqlResult::isValid () const<tt> [protected]</tt>
178</h3>
179Returns TRUE if the result is positioned on a valid record (that
180is, the result is not positioned before the first or after the
181last record); otherwise returns FALSE.
182
183<h3 class=fn><a href="qsqlerror.html">QSqlError</a> <a name="lastError"></a>QSqlResult::lastError () const<tt> [protected]</tt>
184</h3>
185Returns the last error associated with the result.
186
187<h3 class=fn><a href="qstring.html">QString</a> <a name="lastQuery"></a>QSqlResult::lastQuery () const<tt> [protected]</tt>
188</h3>
189Returns the current SQL query text, or <a href="qstring.html#QString-null">QString::null</a> if there is none.
190
191<h3 class=fn>int <a name="numRowsAffected"></a>QSqlResult::numRowsAffected ()<tt> [pure virtual protected]</tt>
192</h3>
193
194<p> Returns the number of rows affected by the last query executed.
195
196<h3 class=fn>bool <a name="reset"></a>QSqlResult::reset ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;query )<tt> [pure virtual protected]</tt>
197</h3>
198
199<p> Sets the result to use the SQL statement <em>query</em> for subsequent
200data retrieval. Derived classes must reimplement this function and
201apply the <em>query</em> to the database. This function is called only
202after the result is set to an inactive state and is positioned
203before the first record of the new result. Derived classes should
204return TRUE if the query was successful and ready to be used,
205or FALSE otherwise.
206
207<h3 class=fn>void <a name="setActive"></a>QSqlResult::setActive ( bool&nbsp;a )<tt> [virtual protected]</tt>
208</h3>
209Protected function provided for derived classes to set the
210internal active state to the value of <em>a</em>.
211<p> <p>See also <a href="#isActive">isActive</a>().
212
213<h3 class=fn>void <a name="setAt"></a>QSqlResult::setAt ( int&nbsp;at )<tt> [virtual protected]</tt>
214</h3>
215Protected function provided for derived classes to set the
216internal (zero-based) result index to <em>at</em>.
217<p> <p>See also <a href="#at">at</a>().
218
219<h3 class=fn>void <a name="setForwardOnly"></a>QSqlResult::setForwardOnly ( bool&nbsp;forward )<tt> [virtual protected]</tt>
220</h3>
221Sets forward only mode to <em>forward</em>. If forward is TRUE only
222<a href="#fetchNext">fetchNext</a>() is allowed for navigating the results. Forward only
223mode needs far less memory since results do not have to be cached.
224forward only mode is off by default.
225<p> <p>See also <a href="#fetchNext">fetchNext</a>().
226
227<h3 class=fn>void <a name="setLastError"></a>QSqlResult::setLastError ( const&nbsp;<a href="qsqlerror.html">QSqlError</a>&nbsp;&amp;&nbsp;e )<tt> [virtual protected]</tt>
228</h3>
229Protected function provided for derived classes to set the last
230error to the value of <em>e</em>.
231<p> <p>See also <a href="#lastError">lastError</a>().
232
233<h3 class=fn>void <a name="setQuery"></a>QSqlResult::setQuery ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;query )<tt> [virtual protected]</tt>
234</h3>
235Sets the current query for the result to <em>query</em>. The result must
236be <a href="#reset">reset</a>() in order to execute the query on the database.
237
238<h3 class=fn>void <a name="setSelect"></a>QSqlResult::setSelect ( bool&nbsp;s )<tt> [virtual protected]</tt>
239</h3>
240Protected function provided for derived classes to indicate
241whether or not the current statement is a SQL SELECT statement.
242The <em>s</em> parameter should be TRUE if the statement is a SELECT
243statement, or FALSE otherwise.
244
245<h3 class=fn>int <a name="size"></a>QSqlResult::size ()<tt> [pure virtual protected]</tt>
246</h3>
247
248<p> Returns the size of the result or -1 if it cannot be determined.
249
250<!-- eof -->
251<hr><p>
252This file is part of the <a href="index.html">Qt toolkit</a>.
253Copyright &copy; 1995-2007
254<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
255<table width=100% cellspacing=0 border=0><tr>
256<td>Copyright &copy; 2007
257<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
258<td align=right><div align=right>Qt 3.3.8</div>
259</table></div></address></body>
260</html>
Note: See TracBrowser for help on using the repository browser.