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.
295 lines
17 KiB
295 lines
17 KiB
13 years ago
|
<!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/qsqlrecord.cpp:151 -->
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>TQSqlRecord 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>TQSqlRecord Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>
|
||
|
|
||
|
<p>The TQSqlRecord class encapsulates a database record, i.e. a
|
||
|
set of database fields.
|
||
|
<a href="#details">More...</a>
|
||
13 years ago
|
<p><tt>#include <<a href="qsqlrecord-h.html">ntqsqlrecord.h</a>></tt>
|
||
|
<p>Inherited by <a href="ntqsqlcursor.html">TQSqlCursor</a> and <a href="ntqsqlindex.html">TQSqlIndex</a>.
|
||
13 years ago
|
<p><a href="qsqlrecord-members.html">List of all member functions.</a>
|
||
|
<h2>Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn><a href="#TQSqlRecord"><b>TQSqlRecord</b></a> ()</li>
|
||
|
<li class=fn><a href="#TQSqlRecord-2"><b>TQSqlRecord</b></a> ( const TQSqlRecord & other )</li>
|
||
|
<li class=fn>TQSqlRecord & <a href="#operator-eq"><b>operator=</b></a> ( const TQSqlRecord & other )</li>
|
||
|
<li class=fn>virtual <a href="#~TQSqlRecord"><b>~TQSqlRecord</b></a> ()</li>
|
||
|
<li class=fn>virtual TQVariant <a href="#value"><b>value</b></a> ( int i ) const</li>
|
||
|
<li class=fn>virtual TQVariant <a href="#value-2"><b>value</b></a> ( const TQString & name ) const</li>
|
||
|
<li class=fn>virtual void <a href="#setValue"><b>setValue</b></a> ( int i, const TQVariant & val )</li>
|
||
|
<li class=fn>virtual void <a href="#setValue-2"><b>setValue</b></a> ( const TQString & name, const TQVariant & val )</li>
|
||
|
<li class=fn>bool <a href="#isGenerated-2"><b>isGenerated</b></a> ( int i ) const</li>
|
||
|
<li class=fn>bool <a href="#isGenerated"><b>isGenerated</b></a> ( const TQString & name ) const</li>
|
||
|
<li class=fn>virtual void <a href="#setGenerated"><b>setGenerated</b></a> ( const TQString & name, bool generated )</li>
|
||
|
<li class=fn>virtual void <a href="#setGenerated-2"><b>setGenerated</b></a> ( int i, bool generated )</li>
|
||
|
<li class=fn>virtual void <a href="#setNull"><b>setNull</b></a> ( int i )</li>
|
||
|
<li class=fn>virtual void <a href="#setNull-2"><b>setNull</b></a> ( const TQString & name )</li>
|
||
|
<li class=fn>bool <a href="#isNull-4"><b>isNull</b></a> ( int i ) const</li>
|
||
|
<li class=fn>bool <a href="#isNull"><b>isNull</b></a> ( const TQString & name ) const</li>
|
||
|
<li class=fn>int <a href="#position"><b>position</b></a> ( const TQString & name ) const</li>
|
||
|
<li class=fn>TQString <a href="#fieldName"><b>fieldName</b></a> ( int i ) const</li>
|
||
|
<li class=fn>TQSqlField * <a href="#field"><b>field</b></a> ( int i )</li>
|
||
|
<li class=fn>TQSqlField * <a href="#field-2"><b>field</b></a> ( const TQString & name )</li>
|
||
|
<li class=fn>const TQSqlField * <a href="#field-3"><b>field</b></a> ( int i ) const</li>
|
||
|
<li class=fn>const TQSqlField * <a href="#field-4"><b>field</b></a> ( const TQString & name ) const</li>
|
||
|
<li class=fn>virtual void <a href="#append"><b>append</b></a> ( const TQSqlField & field )</li>
|
||
|
<li class=fn>virtual void <a href="#insert"><b>insert</b></a> ( int pos, const TQSqlField & field )</li>
|
||
|
<li class=fn>virtual void <a href="#remove"><b>remove</b></a> ( int pos )</li>
|
||
|
<li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#contains"><b>contains</b></a> ( const TQString & name ) const</li>
|
||
|
<li class=fn>virtual void <a href="#clear"><b>clear</b></a> ()</li>
|
||
|
<li class=fn>virtual void <a href="#clearValues"><b>clearValues</b></a> ( bool nullify = FALSE )</li>
|
||
|
<li class=fn>uint <a href="#count"><b>count</b></a> () const</li>
|
||
|
<li class=fn>virtual TQString <a href="#toString"><b>toString</b></a> ( const TQString & prefix = TQString::null, const TQString & sep = "," ) const</li>
|
||
|
<li class=fn>virtual TQStringList <a href="#toStringList"><b>toStringList</b></a> ( const TQString & prefix = TQString::null ) const</li>
|
||
|
</ul>
|
||
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
||
|
|
||
|
|
||
|
The TQSqlRecord class encapsulates a database record, i.e. a
|
||
|
set of database fields.
|
||
|
<p>
|
||
|
|
||
|
<p> The TQSqlRecord class encapsulates the functionality and
|
||
|
characteristics of a database record (usually a table or view within
|
||
|
the database). TQSqlRecords support adding and removing fields as
|
||
|
well as setting and retrieving field values.
|
||
|
<p> TQSqlRecord is <a href="shclass.html#implicitly-shared">implicitly shared</a>. This means you can make copies of
|
||
|
the record in time O(1). If multiple TQSqlRecord instances share
|
||
|
the same data and one is modifying the record's data then this
|
||
|
modifying instance makes a copy and modifies its private copy -
|
||
|
thus it does not affect other instances.
|
||
|
<p> <p>See also <a href="qsqlrecordinfo.html">TQSqlRecordInfo</a> and <a href="database.html">Database Classes</a>.
|
||
|
|
||
|
<hr><h2>Member Function Documentation</h2>
|
||
|
<h3 class=fn><a name="TQSqlRecord"></a>TQSqlRecord::TQSqlRecord ()
|
||
|
</h3>
|
||
|
Constructs an empty record.
|
||
|
|
||
13 years ago
|
<h3 class=fn><a name="TQSqlRecord-2"></a>TQSqlRecord::TQSqlRecord ( const <a href="ntqsqlrecord.html">TQSqlRecord</a> & other )
|
||
13 years ago
|
</h3>
|
||
|
Constructs a copy of <em>other</em>.
|
||
|
|
||
|
<h3 class=fn><a name="~TQSqlRecord"></a>TQSqlRecord::~TQSqlRecord ()<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Destroys the object and frees any allocated resources.
|
||
|
|
||
13 years ago
|
<h3 class=fn>void <a name="append"></a>TQSqlRecord::append ( const <a href="ntqsqlfield.html">TQSqlField</a> & field )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Append a copy of field <em>field</em> to the end of the record.
|
||
|
|
||
13 years ago
|
<p>Reimplemented in <a href="ntqsqlindex.html#append">TQSqlIndex</a>.
|
||
13 years ago
|
<h3 class=fn>void <a name="clear"></a>TQSqlRecord::clear ()<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Removes all the record's fields.
|
||
|
<p> <p>See also <a href="#clearValues">clearValues</a>().
|
||
|
|
||
13 years ago
|
<p>Reimplemented in <a href="ntqsqlcursor.html#clear">TQSqlCursor</a>.
|
||
13 years ago
|
<h3 class=fn>void <a name="clearValues"></a>TQSqlRecord::clearValues ( bool nullify = FALSE )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Clears the value of all fields in the record. If <em>nullify</em> is
|
||
|
TRUE, (the default is FALSE), each field is set to NULL.
|
||
|
|
||
13 years ago
|
<h3 class=fn>bool <a name="contains"></a>TQSqlRecord::contains ( const <a href="ntqstring.html">TQString</a> & name ) const
|
||
13 years ago
|
</h3>
|
||
|
Returns TRUE if there is a field in the record called <em>name</em>;
|
||
|
otherwise returns FALSE.
|
||
|
|
||
|
<h3 class=fn>uint <a name="count"></a>TQSqlRecord::count () const
|
||
|
</h3>
|
||
|
Returns the number of fields in the record.
|
||
|
|
||
13 years ago
|
<h3 class=fn><a href="ntqsqlfield.html">TQSqlField</a> * <a name="field"></a>TQSqlRecord::field ( int i )
|
||
13 years ago
|
</h3>
|
||
|
Returns the field at position <em>i</em> within the record, or 0 if it
|
||
|
cannot be found.
|
||
|
|
||
13 years ago
|
<h3 class=fn><a href="ntqsqlfield.html">TQSqlField</a> * <a name="field-2"></a>TQSqlRecord::field ( const <a href="ntqstring.html">TQString</a> & name )
|
||
13 years ago
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Returns the field called <em>name</em> within the record, or 0 if it
|
||
|
cannot be found. Field names are not case-sensitive.
|
||
|
|
||
13 years ago
|
<h3 class=fn>const <a href="ntqsqlfield.html">TQSqlField</a> * <a name="field-3"></a>TQSqlRecord::field ( int i ) const
|
||
13 years ago
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p>
|
||
13 years ago
|
<h3 class=fn>const <a href="ntqsqlfield.html">TQSqlField</a> * <a name="field-4"></a>TQSqlRecord::field ( const <a href="ntqstring.html">TQString</a> & name ) const
|
||
13 years ago
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Returns the field called <em>name</em> within the record, or 0 if it
|
||
|
cannot be found. Field names are not case-sensitive.
|
||
|
|
||
13 years ago
|
<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="fieldName"></a>TQSqlRecord::fieldName ( int i ) const
|
||
13 years ago
|
</h3>
|
||
|
Returns the name of the field at position <em>i</em>. If the field does
|
||
13 years ago
|
not exist, <a href="ntqstring.html#TQString-null">TQString::null</a> is returned.
|
||
13 years ago
|
|
||
13 years ago
|
<h3 class=fn>void <a name="insert"></a>TQSqlRecord::insert ( int pos, const <a href="ntqsqlfield.html">TQSqlField</a> & field )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Insert a copy of <em>field</em> at position <em>pos</em>. If a field already
|
||
|
exists at <em>pos</em>, it is removed.
|
||
|
|
||
|
<h3 class=fn>bool <a name="isEmpty"></a>TQSqlRecord::isEmpty () const
|
||
|
</h3>
|
||
|
Returns TRUE if there are no fields in the record; otherwise
|
||
|
returns FALSE.
|
||
|
|
||
13 years ago
|
<h3 class=fn>bool <a name="isGenerated"></a>TQSqlRecord::isGenerated ( const <a href="ntqstring.html">TQString</a> & name ) const
|
||
13 years ago
|
</h3>
|
||
|
Returns TRUE if the record has a field called <em>name</em> and this
|
||
|
field is to be generated (the default); otherwise returns FALSE.
|
||
|
<p> <p>See also <a href="#setGenerated">setGenerated</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="isGenerated-2"></a>TQSqlRecord::isGenerated ( int i ) const
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Returns TRUE if the record has a field at position <em>i</em> and this
|
||
|
field is to be generated (the default); otherwise returns FALSE.
|
||
|
<p> <p>See also <a href="#setGenerated">setGenerated</a>().
|
||
|
|
||
13 years ago
|
<h3 class=fn>bool <a name="isNull"></a>TQSqlRecord::isNull ( const <a href="ntqstring.html">TQString</a> & name ) const
|
||
13 years ago
|
</h3>
|
||
|
Returns TRUE if the field called <em>name</em> is NULL or if there is no
|
||
|
field called <em>name</em>; otherwise returns FALSE.
|
||
|
<p> <p>See also <a href="#position">position</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="isNull-4"></a>TQSqlRecord::isNull ( int i ) const
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Returns TRUE if the field <em>i</em> is NULL or if there is no field at
|
||
|
position <em>i</em>; otherwise returns FALSE.
|
||
|
<p> <p>See also <a href="#fieldName">fieldName</a>().
|
||
|
|
||
13 years ago
|
<h3 class=fn><a href="ntqsqlrecord.html">TQSqlRecord</a> & <a name="operator-eq"></a>TQSqlRecord::operator= ( const <a href="ntqsqlrecord.html">TQSqlRecord</a> & other )
|
||
13 years ago
|
</h3>
|
||
|
Sets the record equal to <em>other</em>.
|
||
|
|
||
13 years ago
|
<h3 class=fn>int <a name="position"></a>TQSqlRecord::position ( const <a href="ntqstring.html">TQString</a> & name ) const
|
||
13 years ago
|
</h3>
|
||
|
Returns the position of the field called <em>name</em> within the
|
||
|
record, or -1 if it cannot be found. Field names are not
|
||
|
case-sensitive. If more than one field matches, the first one is
|
||
|
returned.
|
||
|
|
||
|
<h3 class=fn>void <a name="remove"></a>TQSqlRecord::remove ( int pos )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Removes the field at <em>pos</em>. If <em>pos</em> does not exist, nothing
|
||
|
happens.
|
||
|
|
||
13 years ago
|
<p>Reimplemented in <a href="ntqsqlcursor.html#remove">TQSqlCursor</a>.
|
||
|
<h3 class=fn>void <a name="setGenerated"></a>TQSqlRecord::setGenerated ( const <a href="ntqstring.html">TQString</a> & name, bool generated )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Sets the generated flag for the field called <em>name</em> to <em>generated</em>. If the field does not exist, nothing happens. Only
|
||
|
fields that have <em>generated</em> set to TRUE are included in the SQL
|
||
13 years ago
|
that is generated, e.g. by <a href="ntqsqlcursor.html">TQSqlCursor</a>.
|
||
13 years ago
|
<p> <p>See also <a href="#isGenerated">isGenerated</a>().
|
||
|
|
||
13 years ago
|
<p>Reimplemented in <a href="ntqsqlcursor.html#setGenerated">TQSqlCursor</a>.
|
||
13 years ago
|
<h3 class=fn>void <a name="setGenerated-2"></a>TQSqlRecord::setGenerated ( int i, bool generated )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Sets the generated flag for the field <em>i</em> to <em>generated</em>.
|
||
|
<p> <p>See also <a href="#isGenerated">isGenerated</a>().
|
||
|
|
||
13 years ago
|
<p>Reimplemented in <a href="ntqsqlcursor.html#setGenerated-2">TQSqlCursor</a>.
|
||
13 years ago
|
<h3 class=fn>void <a name="setNull"></a>TQSqlRecord::setNull ( int i )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Sets the value of field <em>i</em> to NULL. If the field does not exist,
|
||
|
nothing happens.
|
||
|
|
||
13 years ago
|
<h3 class=fn>void <a name="setNull-2"></a>TQSqlRecord::setNull ( const <a href="ntqstring.html">TQString</a> & name )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Sets the value of the field called <em>name</em> to NULL. If the field
|
||
|
does not exist, nothing happens.
|
||
|
|
||
13 years ago
|
<h3 class=fn>void <a name="setValue"></a>TQSqlRecord::setValue ( int i, const <a href="ntqvariant.html">TQVariant</a> & val )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Sets the value of the field at position <em>i</em> to <em>val</em>. If the
|
||
|
field does not exist, nothing happens.
|
||
|
|
||
13 years ago
|
<p>Examples: <a href="sql.html#x2196">sql/overview/insert/main.cpp</a>, <a href="ntqsqlcursor.html#x2448">sql/overview/insert2/main.cpp</a>, <a href="sql.html#x2270">sql/overview/subclass5/main.cpp</a>, <a href="sql.html#x2203">sql/overview/update/main.cpp</a>, and <a href="sqltable-example.html#x2464">sql/sqltable/main.cpp</a>.
|
||
|
<h3 class=fn>void <a name="setValue-2"></a>TQSqlRecord::setValue ( const <a href="ntqstring.html">TQString</a> & name, const <a href="ntqvariant.html">TQVariant</a> & val )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Sets the value of the field called <em>name</em> to <em>val</em>. If the field
|
||
|
does not exist, nothing happens.
|
||
|
|
||
13 years ago
|
<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="toString"></a>TQSqlRecord::toString ( const <a href="ntqstring.html">TQString</a> & prefix = TQString::null, const <a href="ntqstring.html">TQString</a> & sep = "," ) const<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Returns a list of all the record's field names as a string
|
||
|
separated by <em>sep</em>.
|
||
|
<p> Note that fields which are not generated are <em>not</em> included (see
|
||
|
<a href="#isGenerated">isGenerated</a>()). The returned string is suitable, for example, for
|
||
|
generating SQL SELECT statements. If a <em>prefix</em> is specified,
|
||
|
e.g. a table name, all fields are prefixed in the form:
|
||
|
<p> "<em>prefix</em>.<fieldname>"
|
||
|
|
||
13 years ago
|
<h3 class=fn><a href="ntqstringlist.html">TQStringList</a> <a name="toStringList"></a>TQSqlRecord::toStringList ( const <a href="ntqstring.html">TQString</a> & prefix = TQString::null ) const<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Returns a list of all the record's field names, each having the
|
||
|
prefix <em>prefix</em>.
|
||
|
<p> Note that fields which have generated set to FALSE are <em>not</em>
|
||
|
included. (See <a href="#isGenerated">isGenerated</a>()). If <em>prefix</em> is supplied, e.g.
|
||
|
a table name, all fields are prefixed in the form:
|
||
|
<p> "<em>prefix</em>.<fieldname>"
|
||
|
|
||
13 years ago
|
<h3 class=fn><a href="ntqvariant.html">TQVariant</a> <a name="value"></a>TQSqlRecord::value ( int i ) const<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Returns the value of the field located at position <em>i</em> in the
|
||
|
record. If field <em>i</em> does not exist the resultant behaviour is
|
||
|
undefined.
|
||
13 years ago
|
<p> This function should be used with <a href="ntqsqlquery.html">TQSqlQuery</a>s. When working
|
||
|
with a <a href="ntqsqlcursor.html">TQSqlCursor</a> the <a href="ntqsqlquery.html#value">value(const
|
||
13 years ago
|
TQString&)</a> overload which uses field names is more
|
||
|
appropriate.
|
||
|
|
||
|
<p>Example: <a href="sql.html#x2204">sql/overview/update/main.cpp</a>.
|
||
13 years ago
|
<h3 class=fn><a href="ntqvariant.html">TQVariant</a> <a name="value-2"></a>TQSqlRecord::value ( const <a href="ntqstring.html">TQString</a> & name ) const<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Returns the value of the field called <em>name</em> in the record. If
|
||
|
field <em>name</em> does not exist the resultant behaviour is undefined.
|
||
|
|
||
|
<!-- 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>
|