QSqlQuery and EXPLAIN SELECT syntax
-
QSqlQuery::next() can not get the result from and SQL Query
e.g.
@MariaDB [exscan]> explain select 1;
+------+-------------+-------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+------+---------------+------+---------+------+------+----------------+
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
+------+-------------+-------+------+---------------+------+---------+------+------+----------------+
1 row in set (0.00 sec)@QSqlQuery::numRowsAffected() gives an -1
Is it possible to use these kind of queries ?
-
[quote author="smooker" date="1398581403"]
QSqlQuery::numRowsAffected() gives an -1
[/quote]In my opinion you have received a correct result. Have a look at the documentation of the method "QSqlQuery::numRowsAffected()":http://qt-project.org/doc/qt-5/qsqlquery.html#numRowsAffected:
bq. Returns the number of rows affected by the result's SQL statement, or -1 if it cannot be determined. Note that for SELECT statements, the value is undefined; use size() instead. If the query is not active, -1 is returned.