Public Slots | |
reading the current selected record | |
| QList< QVariant > | allValues () |
| QStringList | fieldNames () |
| int | indexOfField (const QString &name) |
| int | numValues () |
| QMap< QString, QVariant > | record () |
| QVariant | value (int i) |
| QVariant | valueOfField (const QString &name) |
| QList< QVariant > | values () |
send SQL statements | |
| void | bindValue (int i, const QVariant &value) |
| void | bindValue (const QString &name, const QVariant &value) |
| bool | exec () |
| bool | exec (const QString &sqlStatement) |
| bool | execQuery () |
| bool | execQuery (const QString &sqlStatement) |
| bool | isActive () |
| bool | isSelect () |
| bool | isValid () |
| QVariant | lastInsertId () |
| bool | prepare (const QString &sqlStatement) |
| int | rowsAffected () |
| int | size () |
navigate query results | |
| bool | first () |
| bool | last () |
| bool | next () |
| bool | prev () |
| QList<QVariant> MLABSqlQuery::allValues | ( | ) | [slot] |
get all records as a list of QValueList<QVariant>
| void MLABSqlQuery::bindValue | ( | int | i, | |
| const QVariant & | value | |||
| ) | [slot] |
bind the value of placeholder i (starting from 0);
| void MLABSqlQuery::bindValue | ( | const QString & | name, | |
| const QVariant & | value | |||
| ) | [slot] |
bind the value of placeholder name
| bool MLABSqlQuery::exec | ( | ) | [slot] |
execute a prepared query
| bool MLABSqlQuery::exec | ( | const QString & | sqlStatement | ) | [slot] |
execute the given sql statement, returns if it was successfull
Note that using "SELECT table.*" is a bad idea because the indexes of the fields will not have any order
| bool MLABSqlQuery::execQuery | ( | ) | [slot] |
execute a prepared query like above but with an aliased name because exec is a reserved keyword in python
| bool MLABSqlQuery::execQuery | ( | const QString & | sqlStatement | ) | [slot] |
execute the given sql statement, returns if it was successfull
Note that using "SELECT table.*" is a bad idea because the indexes of the fields will not have any order like above but with an aliased name because exec is a reserved keyword in python
| QStringList MLABSqlQuery::fieldNames | ( | ) | [slot] |
returns the names of the fields in the record
| bool MLABSqlQuery::first | ( | ) | [slot] |
set to first result record of a select (returns false if no first record is available)
| int MLABSqlQuery::indexOfField | ( | const QString & | name | ) | [slot] |
get the value index of the given field for usage with "value"
| bool MLABSqlQuery::isActive | ( | ) | [slot] |
returns if a select statement is active and successful
| bool MLABSqlQuery::isSelect | ( | ) | [slot] |
returns if the query is a select statement
| bool MLABSqlQuery::isValid | ( | ) | [slot] |
returns if the query is positioned on a valid record
| bool MLABSqlQuery::last | ( | ) | [slot] |
set to last result record of a select (returns false if no last record is available)
| QVariant MLABSqlQuery::lastInsertId | ( | ) | [slot] |
Returns the object ID of the most recent inserted row if the database supports it.
An invalid QVariant will be returned if the query did not insert any value or if the database does not report the id back. If more than one row was touched by the insert, the behavior is undefined.
| bool MLABSqlQuery::next | ( | ) | [slot] |
set to next result record of a select (returns false if no next record is available)
| int MLABSqlQuery::numValues | ( | ) | [slot] |
returns the number of values in the record
| bool MLABSqlQuery::prepare | ( | const QString & | sqlStatement | ) | [slot] |
set a prepared statement, use exec() to execute the statement
Example 1 (with named placeholders and indices):
query.prepare( "INSERT INTO atable (id, forename, surname) " "VALUES (:id, :forename, :surname)" ); query.bindValue( 0, 1001 ); query.bindValue( 1, "Bart" ); query.bindValue( 2, "Simpson" ); query.exec();
Example 2 (with named placeholder):
query.prepare( "INSERT INTO atable (id, forename, surname) " "VALUES (:id, :forename, :surname)" ); query.bindValue( ":id", 1001 ); query.bindValue( ":forename", "Bart" ); query.bindValue( ":surname", "Simpson" ); query.exec();
Example 3 (with question mark placeholders):
query.prepare( "INSERT INTO atable (id, forename, surname) " "VALUES (?, ?, ?)" ); query.bindValue( 0, 1001 ); query.bindValue( 1, "Bart" ); query.bindValue( 2, "Simpson" ); query.exec();
| bool MLABSqlQuery::prev | ( | ) | [slot] |
set to previous result record of a select (returns false if no previous record is available)
| QMap<QString,QVariant> MLABSqlQuery::record | ( | ) | [slot] |
get the current record of a select as map (fieldnames->values)
| int MLABSqlQuery::rowsAffected | ( | ) | [slot] |
number of rows that where affected by the exec statement (NOT the number of records found with SELECT)
| int MLABSqlQuery::size | ( | ) | [slot] |
size of the resulting records of a SELECT statement (-1 if size is unknown)
| QVariant MLABSqlQuery::value | ( | int | i | ) | [slot] |
get the ith field's value of the current record of the select statement (in order of appearance in the select statement)
| QVariant MLABSqlQuery::valueOfField | ( | const QString & | name | ) | [slot] |
get the value for the named field in the current record
| QList<QVariant> MLABSqlQuery::values | ( | ) | [slot] |
get the values of the fields of the current record
1.5.8