Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. QSqlQuery and EXPLAIN SELECT syntax
Forum Updated to NodeBB v4.3 + New Features

QSqlQuery and EXPLAIN SELECT syntax

Scheduled Pinned Locked Moved C++ Gurus
3 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    smooker
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      [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.

      http://anavi.org/

      1 Reply Last reply
      0
      • S Offline
        S Offline
        smooker
        wrote on last edited by
        #3

        QSqlQuery::size() gave me the same result.
        It turns that, I can not use "EXPLAIN SELECT ..." query, and get its result via QSqlQuery::next().
        Will do workaround.
        Thanks for the answer.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved