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"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { 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 Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main 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 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
|
---|
35 | accessing data from SQL databases.
|
---|
36 | <a href="#details">More...</a>
|
---|
37 | <p><tt>#include <<a href="qsqlresult-h.html">qsqlresult.h</a>></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 QSqlDriver * 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 at )</li>
|
---|
55 | <li class=fn>virtual void <a href="#setActive"><b>setActive</b></a> ( bool a )</li>
|
---|
56 | <li class=fn>virtual void <a href="#setLastError"><b>setLastError</b></a> ( const QSqlError & e )</li>
|
---|
57 | <li class=fn>virtual void <a href="#setQuery"><b>setQuery</b></a> ( const QString & query )</li>
|
---|
58 | <li class=fn>virtual void <a href="#setSelect"><b>setSelect</b></a> ( bool s )</li>
|
---|
59 | <li class=fn>virtual void <a href="#setForwardOnly"><b>setForwardOnly</b></a> ( bool forward )</li>
|
---|
60 | <li class=fn>virtual QVariant <a href="#data"><b>data</b></a> ( int i ) = 0</li>
|
---|
61 | <li class=fn>virtual bool <a href="#isNull"><b>isNull</b></a> ( int i ) = 0</li>
|
---|
62 | <li class=fn>virtual bool <a href="#reset"><b>reset</b></a> ( const QString & query ) = 0</li>
|
---|
63 | <li class=fn>virtual bool <a href="#fetch"><b>fetch</b></a> ( int 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 |
|
---|
74 | The QSqlResult class provides an abstract interface for
|
---|
75 | accessing data from SQL databases.
|
---|
76 | <p>
|
---|
77 |
|
---|
78 | <p> Normally you would use <a href="qsqlquery.html">QSqlQuery</a> instead of QSqlResult since QSqlQuery
|
---|
79 | provides a generic wrapper for database-specific implementations of
|
---|
80 | QSqlResult.
|
---|
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 <a href="qsqldriver.html">QSqlDriver</a> * db )<tt> [protected]</tt>
|
---|
85 | </h3>
|
---|
86 | Protected 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>
|
---|
90 | Destroys 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>
|
---|
94 | Returns 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 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
|
---|
100 | function is only called if the result is in an active state and is
|
---|
101 | positioned on a valid record and <em>i</em> is non-negative.
|
---|
102 | Derived classes must reimplement this function and return the value
|
---|
103 | of field <em>i</em>, or QVariant() if it cannot be determined.
|
---|
104 |
|
---|
105 | <h3 class=fn>const <a href="qsqldriver.html">QSqlDriver</a> * <a name="driver"></a>QSqlResult::driver () const<tt> [protected]</tt>
|
---|
106 | </h3>
|
---|
107 | Returns the driver associated with the result.
|
---|
108 |
|
---|
109 | <h3 class=fn>bool <a name="fetch"></a>QSqlResult::fetch ( int i )<tt> [pure virtual protected]</tt>
|
---|
110 | </h3>
|
---|
111 |
|
---|
112 | <p> Positions the result to an arbitrary (zero-based) index <em>i</em>. This
|
---|
113 | function is only called if the result is in an active state. Derived
|
---|
114 | classes must reimplement this function and position the result to the
|
---|
115 | index <em>i</em>, and call <a href="#setAt">setAt</a>() with an appropriate value. Return TRUE
|
---|
116 | to 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
|
---|
122 | function is only called if the result is in an active state.
|
---|
123 | Derived classes must reimplement this function and position the result
|
---|
124 | to the first record, and call <a href="#setAt">setAt</a>() with an appropriate value.
|
---|
125 | Return 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
|
---|
131 | function is only called if the result is in an active state.
|
---|
132 | Derived classes must reimplement this function and position the result
|
---|
133 | to the last record, and call <a href="#setAt">setAt</a>() with an appropriate value.
|
---|
134 | Return 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>
|
---|
138 | Positions the result to the next available record in the result.
|
---|
139 | This function is only called if the result is in an active state.
|
---|
140 | The default implementation calls <a href="#fetch">fetch</a>() with the next index.
|
---|
141 | Derived classes can reimplement this function and position the result
|
---|
142 | to the next record in some other way, and call <a href="#setAt">setAt</a>() with an
|
---|
143 | appropriate value. Return TRUE to indicate success, or FALSE to
|
---|
144 | signify failure.
|
---|
145 |
|
---|
146 | <h3 class=fn>bool <a name="fetchPrev"></a>QSqlResult::fetchPrev ()<tt> [virtual protected]</tt>
|
---|
147 | </h3>
|
---|
148 | Positions the result to the previous available record in the
|
---|
149 | result. This function is only called if the result is in an active
|
---|
150 | state. The default implementation calls <a href="#fetch">fetch</a>() with the previous
|
---|
151 | index. Derived classes can reimplement this function and position the
|
---|
152 | result to the next record in some other way, and call <a href="#setAt">setAt</a>() with
|
---|
153 | an appropriate value. Return TRUE to indicate success, or FALSE to
|
---|
154 | signify failure.
|
---|
155 |
|
---|
156 | <h3 class=fn>bool <a name="isActive"></a>QSqlResult::isActive () const<tt> [protected]</tt>
|
---|
157 | </h3>
|
---|
158 | Returns TRUE if the result has records to be retrieved; otherwise
|
---|
159 | returns FALSE.
|
---|
160 |
|
---|
161 | <h3 class=fn>bool <a name="isForwardOnly"></a>QSqlResult::isForwardOnly () const<tt> [protected]</tt>
|
---|
162 | </h3>
|
---|
163 | Returns TRUE if you can only scroll forward through a result set;
|
---|
164 | otherwise returns FALSE.
|
---|
165 |
|
---|
166 | <h3 class=fn>bool <a name="isNull"></a>QSqlResult::isNull ( int i )<tt> [pure virtual protected]</tt>
|
---|
167 | </h3>
|
---|
168 |
|
---|
169 | <p> Returns TRUE if the field at position <em>i</em> is NULL; otherwise
|
---|
170 | returns FALSE.
|
---|
171 |
|
---|
172 | <h3 class=fn>bool <a name="isSelect"></a>QSqlResult::isSelect () const<tt> [protected]</tt>
|
---|
173 | </h3>
|
---|
174 | Returns TRUE if the current result is from a SELECT statement;
|
---|
175 | otherwise returns FALSE.
|
---|
176 |
|
---|
177 | <h3 class=fn>bool <a name="isValid"></a>QSqlResult::isValid () const<tt> [protected]</tt>
|
---|
178 | </h3>
|
---|
179 | Returns TRUE if the result is positioned on a valid record (that
|
---|
180 | is, the result is not positioned before the first or after the
|
---|
181 | last 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>
|
---|
185 | Returns 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>
|
---|
189 | Returns 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 <a href="qstring.html">QString</a> & query )<tt> [pure virtual protected]</tt>
|
---|
197 | </h3>
|
---|
198 |
|
---|
199 | <p> Sets the result to use the SQL statement <em>query</em> for subsequent
|
---|
200 | data retrieval. Derived classes must reimplement this function and
|
---|
201 | apply the <em>query</em> to the database. This function is called only
|
---|
202 | after the result is set to an inactive state and is positioned
|
---|
203 | before the first record of the new result. Derived classes should
|
---|
204 | return TRUE if the query was successful and ready to be used,
|
---|
205 | or FALSE otherwise.
|
---|
206 |
|
---|
207 | <h3 class=fn>void <a name="setActive"></a>QSqlResult::setActive ( bool a )<tt> [virtual protected]</tt>
|
---|
208 | </h3>
|
---|
209 | Protected function provided for derived classes to set the
|
---|
210 | internal 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 at )<tt> [virtual protected]</tt>
|
---|
214 | </h3>
|
---|
215 | Protected function provided for derived classes to set the
|
---|
216 | internal (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 forward )<tt> [virtual protected]</tt>
|
---|
220 | </h3>
|
---|
221 | Sets 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
|
---|
223 | mode needs far less memory since results do not have to be cached.
|
---|
224 | forward 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 <a href="qsqlerror.html">QSqlError</a> & e )<tt> [virtual protected]</tt>
|
---|
228 | </h3>
|
---|
229 | Protected function provided for derived classes to set the last
|
---|
230 | error 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 <a href="qstring.html">QString</a> & query )<tt> [virtual protected]</tt>
|
---|
234 | </h3>
|
---|
235 | Sets the current query for the result to <em>query</em>. The result must
|
---|
236 | be <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 s )<tt> [virtual protected]</tt>
|
---|
239 | </h3>
|
---|
240 | Protected function provided for derived classes to indicate
|
---|
241 | whether or not the current statement is a SQL SELECT statement.
|
---|
242 | The <em>s</em> parameter should be TRUE if the statement is a SELECT
|
---|
243 | statement, 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>
|
---|
252 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
253 | Copyright © 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 © 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>
|
---|