summaryrefslogtreecommitdiffstats
path: root/src/sql/tqsqlquery.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql/tqsqlquery.cpp')
-rw-r--r--src/sql/tqsqlquery.cpp196
1 files changed, 98 insertions, 98 deletions
diff --git a/src/sql/tqsqlquery.cpp b/src/sql/tqsqlquery.cpp
index 256694eee..394532d6e 100644
--- a/src/sql/tqsqlquery.cpp
+++ b/src/sql/tqsqlquery.cpp
@@ -99,11 +99,11 @@ void TQSqlResultShared::slotResultDestroyed()
(e.g. \c{SET DATESTYLE=ISO} for PostgreSQL).
Successfully executed SQL statements set the query's state to
- active (isActive() returns TRUE); otherwise the query's state is
+ active (isActive() returns true); otherwise the query's state is
set to inactive. In either case, when executing a new SQL
statement, the query is positioned on an invalid record; an active
query must be navigated to a valid record (so that isValid()
- returns TRUE) before values can be retrieved.
+ returns true) before values can be retrieved.
Navigating records is performed with the following functions:
@@ -288,7 +288,7 @@ void TQSqlQuery::init( const TQString& query, TQSqlDatabase* db )
d = new TQSqlResultShared( 0 );
TQSqlDatabase* database = db;
if ( !database )
- database = TQSqlDatabase::database( TQSqlDatabase::defaultConnection, FALSE );
+ database = TQSqlDatabase::database( TQSqlDatabase::defaultConnection, false );
if ( database )
*this = database->driver()->createQuery();
if ( !query.isNull() )
@@ -308,8 +308,8 @@ TQSqlQuery& TQSqlQuery::operator=( const TQSqlQuery& other )
}
/*!
- Returns TRUE if the query is active and positioned on a valid
- record and the \a field is NULL; otherwise returns FALSE. Note
+ Returns true if the query is active and positioned on a valid
+ record and the \a field is NULL; otherwise returns false. Note
that for some drivers isNull() will not return accurate
information until after an attempt is made to retrieve data.
@@ -319,16 +319,16 @@ TQSqlQuery& TQSqlQuery::operator=( const TQSqlQuery& other )
bool TQSqlQuery::isNull( int field ) const
{
if ( !d->sqlResult )
- return FALSE;
+ return false;
if ( d->sqlResult->isActive() && d->sqlResult->isValid() )
return d->sqlResult->isNull( field );
- return FALSE;
+ return false;
}
/*!
- Executes the SQL in \a query. Returns TRUE and sets the query
+ Executes the SQL in \a query. Returns true and sets the query
state to active if the query was successful; otherwise returns
- FALSE and sets the query state to inactive. The \a query string
+ false and sets the query state to inactive. The \a query string
must use syntax appropriate for the SQL database being queried,
for example, standard SQL.
@@ -345,17 +345,17 @@ bool TQSqlQuery::isNull( int field ) const
bool TQSqlQuery::exec ( const TQString& query )
{
if ( !d->sqlResult )
- return FALSE;
+ return false;
if ( d->sqlResult->extension() && driver()->hasFeature( TQSqlDriver::PreparedQueries ) )
d->sqlResult->extension()->clear();
- d->sqlResult->setActive( FALSE );
+ d->sqlResult->setActive( false );
d->sqlResult->setLastError( TQSqlError() );
d->sqlResult->setAt( TQSql::BeforeFirst );
if ( !driver() ) {
#ifdef QT_CHECK_RANGE
tqWarning("TQSqlQuery::exec: no driver" );
#endif
- return FALSE;
+ return false;
}
if ( d->count > 1 )
*this = driver()->createQuery();
@@ -365,13 +365,13 @@ bool TQSqlQuery::exec ( const TQString& query )
#ifdef QT_CHECK_RANGE
tqWarning("TQSqlQuery::exec: database not open" );
#endif
- return FALSE;
+ return false;
}
if ( query.isNull() || query.length() == 0 ) {
#ifdef QT_CHECK_RANGE
tqWarning("TQSqlQuery::exec: empty query" );
#endif
- return FALSE;
+ return false;
}
#ifdef QT_DEBUG_SQL
tqDebug( "\n TQSqlQuery: " + query );
@@ -462,38 +462,38 @@ const TQSqlResult* TQSqlQuery::result() const
Retrieves the record at position (offset) \a i, if available, and
positions the query on the retrieved record. The first record is
at position 0. Note that the query must be in an active state and
- isSelect() must return TRUE before calling this function.
+ isSelect() must return true before calling this function.
- If \a relative is FALSE (the default), the following rules apply:
+ If \a relative is false (the default), the following rules apply:
\list
\i If \a i is negative, the result is positioned before the
- first record and FALSE is returned.
+ first record and false is returned.
\i Otherwise, an attempt is made to move to the record at position
\a i. If the record at position \a i could not be retrieved, the
- result is positioned after the last record and FALSE is returned. If
- the record is successfully retrieved, TRUE is returned.
+ result is positioned after the last record and false is returned. If
+ the record is successfully retrieved, true is returned.
\endlist
- If \a relative is TRUE, the following rules apply:
+ If \a relative is true, the following rules apply:
\list
\i If the result is currently positioned before the first
record or on the first record, and \a i is negative, there is no
- change, and FALSE is returned.
+ change, and false is returned.
\i If the result is currently located after the last record, and
- \a i is positive, there is no change, and FALSE is returned.
+ \a i is positive, there is no change, and false is returned.
\i If the result is currently located somewhere in the middle,
and the relative offset \a i moves the result below zero, the
- result is positioned before the first record and FALSE is
+ result is positioned before the first record and false is
returned.
\i Otherwise, an attempt is made to move to the record \a i
records ahead of the current record (or \a i records behind the
current record if \a i is negative). If the record at offset \a i
could not be retrieved, the result is positioned after the last
record if \a i >= 0, (or before the first record if \a i is
- negative), and FALSE is returned. If the record is successfully
- retrieved, TRUE is returned.
+ negative), and false is returned. If the record is successfully
+ retrieved, true is returned.
\endlist
\sa next() prev() first() last() at() isActive() isValid()
@@ -501,7 +501,7 @@ const TQSqlResult* TQSqlQuery::result() const
bool TQSqlQuery::seek( int i, bool relative )
{
if ( !isSelect() || !isActive() )
- return FALSE;
+ return false;
beforeSeek();
checkDetach();
int actualIdx;
@@ -509,7 +509,7 @@ bool TQSqlQuery::seek( int i, bool relative )
if ( i < 0 ) {
d->sqlResult->setAt( TQSql::BeforeFirst );
afterSeek();
- return FALSE;
+ return false;
}
actualIdx = i;
} else {
@@ -519,7 +519,7 @@ bool TQSqlQuery::seek( int i, bool relative )
actualIdx = i;
else {
afterSeek();
- return FALSE;
+ return false;
}
break;
case TQSql::AfterLast:
@@ -528,14 +528,14 @@ bool TQSqlQuery::seek( int i, bool relative )
actualIdx = at() + i;
} else {
afterSeek();
- return FALSE;
+ return false;
}
break;
default:
if ( ( at() + i ) < 0 ) {
d->sqlResult->setAt( TQSql::BeforeFirst );
afterSeek();
- return FALSE;
+ return false;
}
actualIdx = at() + i;
break;
@@ -547,40 +547,40 @@ bool TQSqlQuery::seek( int i, bool relative )
tqWarning("TQSqlQuery::seek: cannot seek backwards in a forward only query" );
#endif
afterSeek();
- return FALSE;
+ return false;
}
if ( actualIdx == ( at() + 1 ) && at() != TQSql::BeforeFirst ) {
if ( !d->sqlResult->fetchNext() ) {
d->sqlResult->setAt( TQSql::AfterLast );
afterSeek();
- return FALSE;
+ return false;
}
afterSeek();
- return TRUE;
+ return true;
}
if ( actualIdx == ( at() - 1 ) ) {
if ( !d->sqlResult->fetchPrev() ) {
d->sqlResult->setAt( TQSql::BeforeFirst );
afterSeek();
- return FALSE;
+ return false;
}
afterSeek();
- return TRUE;
+ return true;
}
if ( !d->sqlResult->fetch( actualIdx ) ) {
d->sqlResult->setAt( TQSql::AfterLast );
afterSeek();
- return FALSE;
+ return false;
}
afterSeek();
- return TRUE;
+ return true;
}
/*!
Retrieves the next record in the result, if available, and
positions the query on the retrieved record. Note that the result
- must be in an active state and isSelect() must return TRUE before
- calling this function or it will do nothing and return FALSE.
+ must be in an active state and isSelect() must return true before
+ calling this function or it will do nothing and return false.
The following rules apply:
@@ -590,15 +590,15 @@ bool TQSqlQuery::seek( int i, bool relative )
made to retrieve the first record.
\i If the result is currently located after the last record,
- there is no change and FALSE is returned.
+ there is no change and false is returned.
\i If the result is located somewhere in the middle, an attempt
is made to retrieve the next record.
\endlist
If the record could not be retrieved, the result is positioned after
- the last record and FALSE is returned. If the record is successfully
- retrieved, TRUE is returned.
+ the last record and false is returned. If the record is successfully
+ retrieved, true is returned.
\sa prev() first() last() seek() at() isActive() isValid()
*/
@@ -606,10 +606,10 @@ bool TQSqlQuery::seek( int i, bool relative )
bool TQSqlQuery::next()
{
if ( !isSelect() || !isActive() )
- return FALSE;
+ return false;
beforeSeek();
checkDetach();
- bool b = FALSE;
+ bool b = false;
switch ( at() ) {
case TQSql::BeforeFirst:
b = d->sqlResult->fetchFirst();
@@ -617,29 +617,29 @@ bool TQSqlQuery::next()
return b;
case TQSql::AfterLast:
afterSeek();
- return FALSE;
+ return false;
default:
if ( !d->sqlResult->fetchNext() ) {
d->sqlResult->setAt( TQSql::AfterLast );
afterSeek();
- return FALSE;
+ return false;
}
afterSeek();
- return TRUE;
+ return true;
}
}
/*!
Retrieves the previous record in the result, if available, and
positions the query on the retrieved record. Note that the result
- must be in an active state and isSelect() must return TRUE before
- calling this function or it will do nothing and return FALSE.
+ must be in an active state and isSelect() must return true before
+ calling this function or it will do nothing and return false.
The following rules apply:
\list
\i If the result is currently located before the first record,
- there is no change and FALSE is returned.
+ there is no change and false is returned.
\i If the result is currently located after the last record, an
attempt is made to retrieve the last record.
@@ -649,8 +649,8 @@ bool TQSqlQuery::next()
\endlist
If the record could not be retrieved, the result is positioned
- before the first record and FALSE is returned. If the record is
- successfully retrieved, TRUE is returned.
+ before the first record and false is returned. If the record is
+ successfully retrieved, true is returned.
\sa next() first() last() seek() at() isActive() isValid()
*/
@@ -658,21 +658,21 @@ bool TQSqlQuery::next()
bool TQSqlQuery::prev()
{
if ( !isSelect() || !isActive() )
- return FALSE;
+ return false;
if ( isForwardOnly() ) {
#ifdef QT_CHECK_RANGE
tqWarning("TQSqlQuery::seek: cannot seek backwards in a forward only query" );
#endif
- return FALSE;
+ return false;
}
beforeSeek();
checkDetach();
- bool b = FALSE;
+ bool b = false;
switch ( at() ) {
case TQSql::BeforeFirst:
afterSeek();
- return FALSE;
+ return false;
case TQSql::AfterLast:
b = d->sqlResult->fetchLast();
afterSeek();
@@ -681,20 +681,20 @@ bool TQSqlQuery::prev()
if ( !d->sqlResult->fetchPrev() ) {
d->sqlResult->setAt( TQSql::BeforeFirst );
afterSeek();
- return FALSE;
+ return false;
}
afterSeek();
- return TRUE;
+ return true;
}
}
/*!
Retrieves the first record in the result, if available, and
positions the query on the retrieved record. Note that the result
- must be in an active state and isSelect() must return TRUE before
- calling this function or it will do nothing and return FALSE.
- Returns TRUE if successful. If unsuccessful the query position is
- set to an invalid position and FALSE is returned.
+ must be in an active state and isSelect() must return true before
+ calling this function or it will do nothing and return false.
+ Returns true if successful. If unsuccessful the query position is
+ set to an invalid position and false is returned.
\sa next() prev() last() seek() at() isActive() isValid()
*/
@@ -702,16 +702,16 @@ bool TQSqlQuery::prev()
bool TQSqlQuery::first()
{
if ( !isSelect() || !isActive() )
- return FALSE;
+ return false;
if ( isForwardOnly() && at() > TQSql::BeforeFirst ) {
#ifdef QT_CHECK_RANGE
tqWarning("TQSqlQuery::seek: cannot seek backwards in a forward only query" );
#endif
- return FALSE;
+ return false;
}
beforeSeek();
checkDetach();
- bool b = FALSE;
+ bool b = false;
b = d->sqlResult->fetchFirst();
afterSeek();
return b;
@@ -720,10 +720,10 @@ bool TQSqlQuery::first()
/*!
Retrieves the last record in the result, if available, and
positions the query on the retrieved record. Note that the result
- must be in an active state and isSelect() must return TRUE before
- calling this function or it will do nothing and return FALSE.
- Returns TRUE if successful. If unsuccessful the query position is
- set to an invalid position and FALSE is returned.
+ must be in an active state and isSelect() must return true before
+ calling this function or it will do nothing and return false.
+ Returns true if successful. If unsuccessful the query position is
+ set to an invalid position and false is returned.
\sa next() prev() first() seek() at() isActive() isValid()
*/
@@ -731,10 +731,10 @@ bool TQSqlQuery::first()
bool TQSqlQuery::last()
{
if ( !isSelect() || !isActive() )
- return FALSE;
+ return false;
beforeSeek();
checkDetach();
- bool b = FALSE;
+ bool b = false;
b = d->sqlResult->fetchLast();
afterSeek();
return b;
@@ -744,8 +744,8 @@ bool TQSqlQuery::last()
Returns the size of the result, (number of rows returned), or -1
if the size cannot be determined or if the database does not
support reporting information about query sizes. Note that for
- non-\c SELECT statements (isSelect() returns FALSE), size() will
- return -1. If the query is not active (isActive() returns FALSE),
+ non-\c SELECT statements (isSelect() returns false), size() will
+ return -1. If the query is not active (isActive() returns false),
-1 is returned.
To determine the number of rows affected by a non-SELECT
@@ -766,7 +766,7 @@ int TQSqlQuery::size() const
Returns the number of rows affected by the result's SQL statement,
or -1 if it cannot be determined. Note that for \c SELECT
statements, the value is undefined; see size() instead. If the
- query is not active (isActive() returns FALSE), -1 is returned.
+ query is not active (isActive() returns false), -1 is returned.
\sa size() TQSqlDriver::hasFeature()
*/
@@ -795,56 +795,56 @@ TQSqlError TQSqlQuery::lastError() const
}
/*!
- Returns TRUE if the query is currently positioned on a valid
- record; otherwise returns FALSE.
+ Returns true if the query is currently positioned on a valid
+ record; otherwise returns false.
*/
bool TQSqlQuery::isValid() const
{
if ( !d->sqlResult )
- return FALSE;
+ return false;
return d->sqlResult->isValid();
}
/*!
- Returns TRUE if the query is currently active; otherwise returns
- FALSE.
+ Returns true if the query is currently active; otherwise returns
+ false.
*/
bool TQSqlQuery::isActive() const
{
if ( !d->sqlResult )
- return FALSE;
+ return false;
return d->sqlResult->isActive();
}
/*!
- Returns TRUE if the current query is a \c SELECT statement;
- otherwise returns FALSE.
+ Returns true if the current query is a \c SELECT statement;
+ otherwise returns false.
*/
bool TQSqlQuery::isSelect() const
{
if ( !d->sqlResult )
- return FALSE;
+ return false;
return d->sqlResult->isSelect();
}
/*!
- Returns TRUE if you can only scroll \e forward through a result
- set; otherwise returns FALSE.
+ Returns true if you can only scroll \e forward through a result
+ set; otherwise returns false.
\sa setForwardOnly()
*/
bool TQSqlQuery::isForwardOnly() const
{
if ( !d->sqlResult )
- return FALSE;
+ return false;
return d->sqlResult->isForwardOnly();
}
/*!
- Sets forward only mode to \a forward. If forward is TRUE only
+ Sets forward only mode to \a forward. If forward is true only
next(), and seek() with positive values, are allowed for
navigating the results. Forward only mode needs far less memory
since results do not need to be cached.
@@ -885,9 +885,9 @@ bool TQSqlQuery::checkDetach()
TQString sql = d->sqlResult->lastQuery();
*this = driver()->createQuery();
exec( sql );
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
@@ -930,8 +930,8 @@ void TQSqlQuery::afterSeek()
bool TQSqlQuery::prepare( const TQString& query )
{
if ( !d->sqlResult || !d->sqlResult->extension() )
- return FALSE;
- d->sqlResult->setActive( FALSE );
+ return false;
+ d->sqlResult->setActive( false );
d->sqlResult->setLastError( TQSqlError() );
d->sqlResult->setAt( TQSql::BeforeFirst );
d->sqlResult->extension()->clear();
@@ -939,7 +939,7 @@ bool TQSqlQuery::prepare( const TQString& query )
#ifdef QT_CHECK_RANGE
tqWarning("TQSqlQuery::prepare: no driver" );
#endif
- return FALSE;
+ return false;
}
if ( d->count > 1 )
*this = driver()->createQuery();
@@ -948,13 +948,13 @@ bool TQSqlQuery::prepare( const TQString& query )
#ifdef QT_CHECK_RANGE
tqWarning("TQSqlQuery::prepare: database not open" );
#endif
- return FALSE;
+ return false;
}
if ( query.isNull() || query.length() == 0 ) {
#ifdef QT_CHECK_RANGE
tqWarning("TQSqlQuery::prepare: empty query" );
#endif
- return FALSE;
+ return false;
}
#ifdef QT_DEBUG_SQL
tqDebug( "\n TQSqlQuery: " + query );
@@ -997,15 +997,15 @@ bool TQSqlQuery::prepare( const TQString& query )
d->sqlResult->extension()->holders.append( Holder( rx.cap(0), i ) );
i += rx.matchedLength();
}
- return TRUE; // fake prepares should always succeed
+ return true; // fake prepares should always succeed
}
}
/*!
\overload
- Executes a previously prepared SQL query. Returns TRUE if the
- query executed successfully; otherwise returns FALSE.
+ Executes a previously prepared SQL query. Returns true if the
+ query executed successfully; otherwise returns false.
\sa prepare(), bindValue(), addBindValue()
*/
@@ -1013,7 +1013,7 @@ bool TQSqlQuery::exec()
{
bool ret;
if ( !d->sqlResult || !d->sqlResult->extension() )
- return FALSE;
+ return false;
if ( driver()->hasFeature( TQSqlDriver::PreparedQueries ) ) {
ret = d->sqlResult->extension()->exec();
} else {