How to list all MySQL queries in a page?

Discussion in 'PHP' started by anilinkz, Nov 14, 2010.

  1. #1
    question says it all....

    i need to know what queries are being run.


    TIA
     
    anilinkz, Nov 14, 2010 IP
  2. tnd8

    tnd8 Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    again, there are 2 ways for u ^__^

    1. if you are using a db library. Check manual for function to list all queries.

    2. write your own function to save all sql content any time you query :)
     
    tnd8, Nov 14, 2010 IP
  3. imocoder

    imocoder Member

    Messages:
    45
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #3
    You can collect all of your queries into a global variable and at the end of your file you could list the content of this variable.
    
    //............
    
    function db_query($sql) {
        global $my_queries;
        $my_queries[] = $sql;
        mysql_query($sql);
    }
    
    //somewhere at the end
    global $my_queries;
    print_r($my_queries);
    
    PHP:
     
    imocoder, Nov 15, 2010 IP
  4. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #4
    ThePHPMaster, Nov 15, 2010 IP