Results 1 to 3 of 3

Thread: How to know not insert or delete query?

  1. #1
    Join Date
    Jul 2007
    Posts
    35
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to know not insert or delete query?

    How to know is query string is only select query , not insert or delete query ?

    I want to write function like that in my library. Is there any way it is SELECT query and not contains any insert,update or delete statements ?

    Thanks in advance
    Ramazan

    My code will like this:

    QList<T> executeCustomSelectQuery(const QString & iSelectQuery)
    {
    QList<T> retList;
    QSqlQuery query(iSelectQuery);
    if(isSelectQuery)//I dont know how to know is SELECT query and not contains any insert,update or //delete (One way may be seach in input query string but i don't know it is safe)
    {
    while ( query.next() )
    {
    T value= query.value(0).getValue<T>();
    retList<<value;
    }
    }
    return retList;
    }



    }

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to know not insert or delete query?

    You should set the permissions on your database so that insert/delete/update can only be done by people who are granted those rights.
    Do not mess up your code with difficult and un-save checks.

    Bonus: That way you only have to deal with security at one place.

  3. #3
    Join Date
    Jul 2007
    Posts
    35
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to know not insert or delete query?

    Thanks for your reply.

    But at this point, I can't set any permission to table. I must do check with code.

Similar Threads

  1. SQL query
    By JD2000 in forum Newbie
    Replies: 4
    Last Post: 1st December 2009, 15:21
  2. i need to know insert and delete methods in qsql for phone book application
    By gaurav purohit in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 15th September 2009, 15:04
  3. MS SQL Query
    By baray98 in forum General Programming
    Replies: 0
    Last Post: 14th July 2009, 05:25
  4. Replies: 4
    Last Post: 19th February 2009, 12:10
  5. INSERT query with MySQL problem
    By timmyg in forum Qt Programming
    Replies: 10
    Last Post: 20th March 2008, 22:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.