61 # define Q_NO_MYSQL_EMBEDDED 67 #if MYSQL_VERSION_ID >= 40108 71 #if MYSQL_VERSION_ID >= 40100 72 # define Q_CLIENT_MULTI_STATEMENTS CLIENT_MULTI_STATEMENTS 74 # define Q_CLIENT_MULTI_STATEMENTS 0 97 #ifdef QT_NO_TEXTCODEC 107 #ifdef QT_NO_TEXTCODEC 117 #ifdef QT_NO_TEXTCODEC 127 #ifdef QT_NO_DATESTRING 139 #ifdef QT_NO_DATESTRING 151 #ifdef QT_NO_DATESTRING 170 rowsAffected(0), hasBlobs(false)
171 #
if MYSQL_VERSION_ID >= 40108
172 , stmt(0), meta(0), inBinds(0), outBinds(0)
174 , preparedQuery(false)
176 connect(dp,
SIGNAL(destroyed()),
this,
SLOT(driverDestroyed()));
193 : outField(0), nullIndicator(false), bufLength(0ul),
205 #if MYSQL_VERSION_ID >= 40108 210 MYSQL_BIND *outBinds;
219 #ifndef QT_NO_TEXTCODEC 222 #if MYSQL_VERSION_ID >= 32321 225 return heuristicCodec;
229 #endif // QT_NO_TEXTCODEC 234 const char *cerr = p->
mysql ? mysql_error(p->
mysql) : 0;
237 type, mysql_errno(p->
mysql));
245 case FIELD_TYPE_TINY :
246 case FIELD_TYPE_SHORT :
247 case FIELD_TYPE_LONG :
248 case FIELD_TYPE_INT24 :
251 case FIELD_TYPE_YEAR :
254 case FIELD_TYPE_LONGLONG :
257 case FIELD_TYPE_FLOAT :
258 case FIELD_TYPE_DOUBLE :
259 case FIELD_TYPE_DECIMAL :
260 #if defined(FIELD_TYPE_NEWDECIMAL) 261 case FIELD_TYPE_NEWDECIMAL:
265 case FIELD_TYPE_DATE :
268 case FIELD_TYPE_TIME :
271 case FIELD_TYPE_DATETIME :
272 case FIELD_TYPE_TIMESTAMP :
275 case FIELD_TYPE_STRING :
276 case FIELD_TYPE_VAR_STRING :
277 case FIELD_TYPE_BLOB :
278 case FIELD_TYPE_TINY_BLOB :
279 case FIELD_TYPE_MEDIUM_BLOB :
280 case FIELD_TYPE_LONG_BLOB :
284 case FIELD_TYPE_ENUM :
285 case FIELD_TYPE_SET :
304 #if MYSQL_VERSION_ID >= 40108 309 const char *cerr = mysql_stmt_error(stmt);
312 type, mysql_stmt_errno(stmt));
315 static bool qIsBlob(
int t)
317 return t == MYSQL_TYPE_TINY_BLOB
318 || t == MYSQL_TYPE_BLOB
319 || t == MYSQL_TYPE_MEDIUM_BLOB
320 || t == MYSQL_TYPE_LONG_BLOB;
323 static bool qIsInteger(
int t)
325 return t == MYSQL_TYPE_TINY
326 || t == MYSQL_TYPE_SHORT
327 || t == MYSQL_TYPE_LONG
328 || t == MYSQL_TYPE_LONGLONG
329 || t == MYSQL_TYPE_INT24;
336 MYSQL_FIELD *fieldInfo;
339 for(i = 0; i < fields.count(); ++i) {
340 fieldInfo = fields.at(i).myField;
341 if (qIsBlob(inBinds[i].buffer_type) && meta && fieldInfo) {
343 bind->buffer_length = fieldInfo->max_length;
344 delete[]
static_cast<char*
>(bind->buffer);
345 bind->buffer =
new char[fieldInfo->max_length];
346 fields[i].outField =
static_cast<char*
>(bind->buffer);
358 meta = mysql_stmt_result_metadata(stmt);
362 fields.resize(mysql_num_fields(meta));
364 inBinds =
new MYSQL_BIND[fields.size()];
365 memset(inBinds, 0, fields.size() *
sizeof(MYSQL_BIND));
367 MYSQL_FIELD *fieldInfo;
369 while((fieldInfo = mysql_fetch_field(meta))) {
370 QMyField &f = fields[i];
371 f.myField = fieldInfo;
374 if (qIsBlob(fieldInfo->type)) {
378 fieldInfo->length = 0;
385 if (qIsInteger(fieldInfo->type)) {
386 fieldInfo->length = MAX_BIGINT_WIDTH;
388 fieldInfo->type = MYSQL_TYPE_STRING;
391 field =
new char[fieldInfo->length + 1];
392 memset(field, 0, fieldInfo->length + 1);
394 bind->buffer_type = fieldInfo->type;
395 bind->buffer = field;
396 bind->buffer_length = f.bufLength = fieldInfo->length + 1;
397 bind->is_null = &f.nullIndicator;
398 bind->length = &f.bufLength;
421 #if MYSQL_VERSION_ID >= 40108 436 #if MYSQL_VERSION_ID >= 40100 440 mysql_free_result(res);
444 #if MYSQL_VERSION_ID >= 40108 446 if (mysql_stmt_close(
d->stmt))
447 qWarning(
"QMYSQLResult::cleanup: unable to free statement handle");
452 mysql_free_result(
d->meta);
457 for (i = 0; i <
d->
fields.count(); ++i)
458 delete[]
d->
fields[i].outField;
461 delete[]
d->outBinds;
495 #if MYSQL_VERSION_ID >= 40108 496 mysql_stmt_data_seek(
d->stmt, i);
498 int nRC = mysql_stmt_fetch(
d->stmt);
500 #ifdef MYSQL_DATA_TRUNCATED 501 if (nRC == 1 || nRC == MYSQL_DATA_TRUNCATED)
528 #if MYSQL_VERSION_ID >= 40108 529 int nRC = mysql_stmt_fetch(
d->stmt);
531 #ifdef MYSQL_DATA_TRUNCATED 532 if (nRC == 1 || nRC == MYSQL_DATA_TRUNCATED)
535 #endif // MYSQL_DATA_TRUNCATED 562 my_ulonglong numRows;
564 #if MYSQL_VERSION_ID >= 40108 565 numRows = mysql_stmt_num_rows(
d->stmt);
570 numRows = mysql_num_rows(
d->
result);
572 if (
at() ==
int(numRows))
576 return fetch(numRows - 1);
593 qWarning(
"QMYSQLResult::data: column %d out of range", field);
610 if (
d->
row[field] == NULL) {
614 fieldLength = mysql_fetch_lengths(
d->
result)[field];
674 qWarning(
"QMYSQLResult::data: unknown data type");
681 return d->
fields.at(field).nullIndicator;
683 return d->
row[field] == NULL;
713 for(
int i = 0; i < numFields; i++) {
714 MYSQL_FIELD* field = mysql_fetch_field_direct(
d->
result, i);
727 #if MYSQL_VERSION_ID >= 40108 728 return mysql_stmt_num_rows(
d->stmt);
733 return int(mysql_num_rows(
d->
result));
749 #if MYSQL_VERSION_ID >= 40108 750 quint64 id = mysql_stmt_insert_id(
d->stmt);
769 #if MYSQL_VERSION_ID >= 40108 776 mysql_field_seek(res, 0);
777 MYSQL_FIELD* field = mysql_fetch_field(res);
780 field = mysql_fetch_field(res);
783 mysql_field_seek(res, 0);
791 #if MYSQL_VERSION_ID >= 40100 800 for (
int i = 0; i <
d->
fields.count(); ++i)
801 delete[]
d->
fields[i].outField;
809 }
else if (status == -1) {
815 if (!
d->
result && numFields > 0) {
826 for (
int i = 0; i < numFields; i++) {
827 MYSQL_FIELD* field = mysql_fetch_field_direct(
d->
result, i);
852 #if MYSQL_VERSION_ID >= 40108 859 MYSQL_TIME *myTime =
new MYSQL_TIME;
860 memset(myTime, 0,
sizeof(MYSQL_TIME));
863 myTime->hour = time.
hour();
864 myTime->minute = time.
minute();
865 myTime->second = time.
second();
866 myTime->second_part = time.
msec();
869 myTime->year = date.
year();
870 myTime->month = date.
month();
871 myTime->day = date.
day();
881 #if MYSQL_VERSION_ID >= 40108 908 if (mysql_stmt_param_count(
d->stmt) > 0) {
909 d->outBinds =
new MYSQL_BIND[mysql_stmt_param_count(
d->stmt)];
930 MYSQL_BIND* currBind;
937 r = mysql_stmt_reset(
d->stmt);
944 if (mysql_stmt_param_count(
d->stmt) > 0 &&
945 mysql_stmt_param_count(
d->stmt) == (
uint)values.
count()) {
948 for (
int i = 0; i < values.
count(); ++i) {
952 currBind = &
d->outBinds[i];
954 nullVector[i] =
static_cast<my_bool
>(val.
isNull());
955 currBind->is_null = &nullVector[i];
956 currBind->length = 0;
957 currBind->is_unsigned = 0;
959 switch (val.
type()) {
961 currBind->buffer_type = MYSQL_TYPE_BLOB;
970 timeVector.
append(myTime);
972 currBind->buffer = myTime;
975 currBind->buffer_type = MYSQL_TYPE_TIME;
976 myTime->time_type = MYSQL_TIMESTAMP_TIME;
979 currBind->buffer_type = MYSQL_TYPE_DATE;
980 myTime->time_type = MYSQL_TIMESTAMP_DATE;
983 currBind->buffer_type = MYSQL_TYPE_DATETIME;
984 myTime->time_type = MYSQL_TIMESTAMP_DATETIME;
989 currBind->buffer_length =
sizeof(MYSQL_TIME);
990 currBind->length = 0;
994 currBind->buffer_type = MYSQL_TYPE_LONG;
995 currBind->buffer =
data;
996 currBind->buffer_length =
sizeof(int);
1000 currBind->buffer_type = MYSQL_TYPE_TINY;
1001 currBind->buffer =
data;
1002 currBind->buffer_length =
sizeof(bool);
1003 currBind->is_unsigned =
false;
1006 currBind->buffer_type = MYSQL_TYPE_DOUBLE;
1007 currBind->buffer =
data;
1008 currBind->buffer_length =
sizeof(double);
1012 currBind->buffer_type = MYSQL_TYPE_LONGLONG;
1013 currBind->buffer =
data;
1014 currBind->buffer_length =
sizeof(
qint64);
1021 currBind->buffer_type = MYSQL_TYPE_STRING;
1022 currBind->buffer =
const_cast<char *
>(ba.
constData());
1023 currBind->buffer_length = ba.
length();
1028 r = mysql_stmt_bind_param(
d->stmt,
d->outBinds);
1036 r = mysql_stmt_execute(
d->stmt);
1051 my_bool update_max_length =
true;
1053 r = mysql_stmt_bind_result(
d->stmt,
d->inBinds);
1060 mysql_stmt_attr_set(
d->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &update_max_length);
1062 r = mysql_stmt_store_result(
d->stmt);
1074 r = mysql_stmt_bind_result(
d->stmt,
d->inBinds);
1094 #ifndef Q_NO_MYSQL_EMBEDDED 1095 # if MYSQL_VERSION_ID >= 40000 1096 if (qMySqlInitHandledByUser || qMySqlConnectionCount > 1)
1099 # if (MYSQL_VERSION_ID >= 40110 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50003 1100 if (mysql_library_init(0, 0, 0)) {
1102 if (mysql_server_init(0, 0, 0)) {
1104 qWarning(
"QMYSQLDriver::qServerInit: unable to start server.");
1106 # endif // MYSQL_VERSION_ID 1107 #endif // Q_NO_MYSQL_EMBEDDED 1112 #ifndef Q_NO_MYSQL_EMBEDDED 1113 # if MYSQL_VERSION_ID > 40000 1114 # if (MYSQL_VERSION_ID >= 40110 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50003 1115 mysql_library_end();
1140 d->
mysql = (MYSQL *) con;
1141 #ifndef QT_NO_TEXTCODEC 1146 if (qMySqlConnectionCount == 1)
1147 qMySqlInitHandledByUser =
true;
1157 qMySqlConnectionCount++;
1162 qMySqlConnectionCount--;
1163 if (qMySqlConnectionCount == 0 && !qMySqlInitHandledByUser)
1173 #ifdef CLIENT_TRANSACTIONS 1175 if ((
d->
mysql->server_capabilities & CLIENT_TRANSACTIONS) == CLIENT_TRANSACTIONS)
1194 #if MYSQL_VERSION_ID >= 40108 1200 #if MYSQL_VERSION_ID >= 40100 1212 optionFlags |= CLIENT_COMPRESS;
1214 optionFlags |= CLIENT_FOUND_ROWS;
1216 optionFlags |= CLIENT_IGNORE_SPACE;
1218 optionFlags |= CLIENT_INTERACTIVE;
1220 optionFlags |= CLIENT_NO_SCHEMA;
1222 optionFlags |= CLIENT_ODBC;
1224 optionFlags |= CLIENT_SSL;
1247 #if MYSQL_VERSION_ID >= 50000 1248 my_bool reconnect=
false;
1252 for (
int i = 0; i < opts.count(); ++i) {
1253 QString tmp(opts.at(i).simplified());
1255 if ((idx = tmp.indexOf(
QLatin1Char(
'='))) != -1) {
1260 #if MYSQL_VERSION_ID >= 50000 1269 qWarning(
"QMYSQLDriver::open: Illegal connect option value '%s'",
1270 tmp.toLocal8Bit().constData());
1276 if ((
d->
mysql = mysql_init((MYSQL*) 0)) &&
1277 mysql_real_connect(
d->
mysql,
1278 host.
isNull() ?
static_cast<const char *
>(0)
1280 user.
isNull() ?
static_cast<const char *
>(0)
1282 password.
isNull() ?
static_cast<const char *
>(0)
1284 db.
isNull() ?
static_cast<const char *
>(0)
1286 (port > -1) ? port : 0,
1287 unixSocket.isNull() ?
static_cast<const char *
>(0)
1288 : unixSocket.toLocal8Bit().constData(),
1298 #if MYSQL_VERSION_ID >= 50000 1300 mysql_options(
d->
mysql, MYSQL_OPT_RECONNECT, &reconnect);
1311 #if (MYSQL_VERSION_ID >= 40113 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50007 1313 mysql_set_character_set(
d->
mysql,
"utf8");
1315 #ifndef QT_NO_TEXTCODEC 1319 #if MYSQL_VERSION_ID >= 40108 1321 && mysql_get_server_version(
d->
mysql) >= 40100;
1326 #ifndef QT_NO_THREAD 1327 mysql_thread_init();
1339 #ifndef QT_NO_THREAD 1357 #if MYSQL_VERSION_ID >= 40100 1358 if( mysql_get_server_version(
d->
mysql) < 50000)
1366 MYSQL_RES* tableRes = mysql_list_tables(
d->
mysql, NULL);
1370 mysql_data_seek(tableRes, i);
1371 row = mysql_fetch_row(tableRes);
1377 mysql_free_result(tableRes);
1378 #if MYSQL_VERSION_ID >= 40100 1436 while ((field = mysql_fetch_field(r)))
1438 mysql_free_result(r);
1449 #ifndef CLIENT_TRANSACTIONS 1453 qWarning(
"QMYSQLDriver::beginTransaction: Database not open");
1456 if (mysql_query(
d->
mysql,
"BEGIN WORK")) {
1466 #ifndef CLIENT_TRANSACTIONS 1470 qWarning(
"QMYSQLDriver::commitTransaction: Database not open");
1473 if (mysql_query(
d->
mysql,
"COMMIT")) {
1483 #ifndef CLIENT_TRANSACTIONS 1487 qWarning(
"QMYSQLDriver::rollbackTransaction: Database not open");
1490 if (mysql_query(
d->
mysql,
"ROLLBACK")) {
1504 switch(field.
type()) {
1514 char* buffer =
new char[ba.
size() * 2 + 1];
1515 int escapedSize = int(mysql_real_escape_string(
d->
mysql, buffer,
1522 qWarning(
"QMYSQLDriver::formatValue: Database not open");
1545 return identifier.
size() > 2
1552 #include "qsql_mysql.moc" The QVariant class acts like a union for the most common Qt data types.
The QSqlError class provides SQL database error information.
The QSqlIndex class provides functions to manipulate and describe database indexes.
static QTextCodec * codecForLocale()
Returns a pointer to the codec most suitable for this locale.
QSqlResult * createResult() const
Creates an empty SQL result on the database.
static QVariant qTimeFromString(const QString &val)
const QSqlDriver * driver() const
Returns the driver associated with the result.
qlonglong toLongLong(bool *ok=0, int base=10) const
Returns the string converted to a long long using base base, which is 10 by default and must be betwe...
bool isNull(int field)
Returns true if the field at position index in the current row is null; otherwise returns false...
bool commitTransaction()
This function is called to commit a transaction.
static void setOptionFlag(uint &optionFlags, const QString &opt)
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
QVariant qVariantFromValue(const T &)
virtual void setOpen(bool o)
This function sets the open state of the database to open.
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false...
char * data()
Returns a pointer to the data stored in the byte array.
qulonglong toULongLong(bool *ok=0, int base=10) const
Returns the string converted to an unsigned long long using base base, which is 10 by default and mus...
DriverFeature
This enum contains a list of features a driver might support.
QMYSQLDriver(QObject *parent=0)
static int qMySqlConnectionCount
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
void append(const QSqlField &field)
Appends the field field to the list of indexed fields.
QVariant value() const
Returns the value of the field as a QVariant.
QString & replace(int i, int len, QChar after)
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
QString & prepend(QChar c)
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
bool reset(const QString &query)
Sets the result to use the SQL statement query for subsequent data retrieval.
The QSqlQuery class provides a means of executing and manipulating SQL statements.
int size()
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
bool fetchFirst()
Positions the result to the first record (row 0) in the result.
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QMYSQLDriverPrivate *p)
void setPrecision(int precision)
Sets the field's precision.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
int day() const
Returns the day of the month (1 to 31) of this date.
static LibLoadStatus status
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QDate class provides date functions.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int msec() const
Returns the millisecond part (0 to 999) of the time.
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
The QSqlRecord class encapsulates a database record.
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
The QString class provides a Unicode character string.
bool isActive() const
Returns true if the query is active.
int at() const
Returns the current (zero-based) row position of the result.
The QVector class is a template class that provides a dynamic array.
The QObject class is the base class of all Qt objects.
static QSqlField qToField(MYSQL_FIELD *field, QTextCodec *tc)
friend class QMYSQLResultPrivate
QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
QString escapeIdentifier(const QString &identifier, IdentifierType type) const
Returns the identifier escaped according to the database rules.
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index...
QString formatValue(const QSqlField &field, bool trimStrings) const
Returns a string representation of the field value for the database.
void resize(int size)
Sets the size of the vector to size.
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
int numRowsAffected()
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
bool preparedQuerysEnabled
ErrorType
This enum type describes the context in which the error occurred, e.
void reserve(int size)
Attempts to allocate memory for at least size characters.
static QVariant qDateTimeFromString(QString &val)
static QDateTime fromString(const QString &s, Qt::DateFormat f=Qt::TextDate)
Returns the QDateTime represented by the string, using the format given, or an invalid datetime if th...
void append(const T &t)
Inserts value at the end of the list.
bool beginTransaction()
This function is called to begin a transaction.
The QTime class provides clock time functions.
#define QT_BEGIN_NAMESPACE
This macro expands to.
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
const QMYSQLDriver * driver
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
int size() const
Returns the number of characters in this string.
QVariant lastInsertId() const
Returns the object ID of the most recent inserted row if the database supports it.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
friend class QMYSQLResult
QVariant handle() const
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
bool hasFeature(DriverFeature f) const
Returns true if the driver supports feature feature; otherwise returns false.
The QStringList class provides a list of strings.
void setLength(int fieldLength)
Sets the field's length to fieldLength.
void append(const T &t)
Inserts value at the end of the vector.
QSqlRecord record(const QString &tablename) const
Returns a QSqlRecord populated with the names of the fields in table tableName.
Q_CORE_EXPORT void qWarning(const char *,...)
int second() const
Returns the second part (0 to 59) of the time.
bool fetchLast()
Positions the result to the last record (last row) in the result.
void setName(const QString &name)
Sets the name of the index to name.
static QTextCodec * codec(MYSQL *mysql)
Type
This enum type defines the types of variable that a QVariant can contain.
void setCursorName(const QString &cursorName)
Sets the name of the cursor that the index is associated with to cursorName.
static bool qMySqlInitHandledByUser
QVector< QMyField > fields
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
int minute() const
Returns the minute part (0 to 59) of the time.
virtual bool exec()
Executes the query, returning true if successful; otherwise returns false.
virtual bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
QVariant::Type type() const
Returns the field's type as stored in the database.
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
bool fetch(int i)
Positions the result to an arbitrary (zero-based) row index.
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
QSqlField field(int i) const
Returns the field at position index.
virtual void virtual_hook(int id, void *data)
static QVariant qDateFromString(const QString &val)
const T & at(int i) const
Returns the item at index position i in the vector.
QSqlIndex primaryIndex(const QString &tablename) const
Returns the primary index for table tableName.
bool fetchNext()
Positions the result to the next available record (row) in the result.
QVariant data(int field)
Returns the data for field index in the current row as a QVariant.
static QTime fromString(const QString &s, Qt::DateFormat f=Qt::TextDate)
Returns the time represented in the string as a QTime using the format given, or an invalid time if t...
static QString toUnicode(QTextCodec *tc, const char *str)
int length() const
Same as size().
virtual QByteArray name() const =0
QTextCodec subclasses must reimplement this function.
const char * constData() const
Returns a pointer to the data stored in the byte array.
bool isNull() const
Returns true if this string is null; otherwise returns false.
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
void setRequired(bool required)
Sets the required status of this field to Required if required is true; otherwise sets it to Optional...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString & append(QChar c)
static void qLibraryInit()
The QDateTime class provides date and time functions.
static void qLibraryEnd()
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
QMYSQLResultPrivate(const QMYSQLDriver *dp, const QMYSQLResult *d)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Type type() const
Returns the storage type of the value stored in the variant.
QObject * parent() const
Returns a pointer to the parent object.
bool isNull() const
Returns true if the field's value is NULL; otherwise returns false.
const void * constData() const
virtual QString formatValue(const QSqlField &field, bool trimStrings=false) const
Returns a string representation of the field value for the database.
static QDate fromString(const QString &s, Qt::DateFormat f=Qt::TextDate)
Returns the QDate represented by the string, using the format given, or an invalid date if the string...
double toDouble(bool *ok=0) const
Returns the string converted to a double value.
uint toUInt(bool *ok=0, int base=10) const
Returns the string converted to an unsigned int using base base, which is 10 by default and must be b...
if(void) toggleToolbarShown
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
void virtual_hook(int id, void *data)
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
int size() const
Returns the number of bytes in this byte array.
QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active...
#define Q_CLIENT_MULTI_STATEMENTS
QMYSQLResult(const QMYSQLDriver *db)
static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags)
int year() const
Returns the year of this date.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
static QByteArray fromUnicode(QTextCodec *tc, const QString &str)
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
The QSqlField class manipulates the fields in SQL database tables and views.
bool exec(const QString &query)
Executes the SQL in query.
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
void setAutoValue(bool autoVal)
Marks the field as an auto-generated value if autoVal is true.
The QTextCodec class provides conversions between text encodings.
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
QVector< QVariant > & boundValues() const
Returns a vector of the result's bound values for the current record (row).
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
QVariant value(int i) const
Returns the value of field index in the current record.
QString & insert(int i, QChar c)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
bool next()
Retrieves the next record in the result, if available, and positions the query on the retrieved recor...
bool open(const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts)
Derived classes must reimplement this pure virtual function to open a database connection on database...
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases...
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
bool rollbackTransaction()
This function is called to rollback a transaction.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
IdentifierType
This enum contains a list of SQL identifier types.
void close()
Derived classes must reimplement this pure virtual function in order to close the database connection...
QStringList tables(QSql::TableType) const
Returns a list of the names of the tables in the database.
int hour() const
Returns the hour part (0 to 23) of the time.
void setSqlType(int type)