0

I need an app based (session independent) counter that gives me the order of the queries that are done to server. Does PDO (or MySQL) has an internal counter for that? If it does not have how a can I get the order of the queries without writing to db or using the file system.

What I do right now is

  1. construct my PDO object :

    $dbpdo = new PDO("mysql:host=$db_host;dbname=$db_name", $db_username, 
    $db_password, array(PDO::ATTR_PERSISTENT => true));
    $dbpdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $dbpdo->setAttribute(PDO::ATTR_TIMEOUT, 30);
    $dbpdo->query("SET NAMES utf8");  
    
  2. Do the query:

    $q = $dbpdo->prepare($sql);
    $q-> execute($arr);
    

I need the order number of the query (app based).

Script47
  • 14,230
  • 4
  • 45
  • 66
user1022786
  • 55
  • 1
  • 3
  • 9
  • You talk about 'count', 'order' and 'order number' of queries. Which one is it? – KIKO Software Jul 11 '18 at 22:34
  • They are all same like 1,2,3,4,.... eg . How can I find the $order here in this array? $counter[$order]=$sql – user1022786 Jul 11 '18 at 23:06
  • it depends on what you want exactly `PHP MyAdmin` keeps exact records of all calls made to data base and in the order it was made. but if your trying to build an app that can do that for you then have a look at `adminer-4.3.1` or higher its a sever side interface written in php it could give you a better insight to what you need. – Bobby Axe Jul 12 '18 at 00:02
  • @BobbyAxe : I didn't know PHPMyAdmin kept exact records of all calls made to the database. Where can I can them? – KIKO Software Jul 12 '18 at 06:00
  • I think this question asks the impossibe: Wanting an exact record of every query without using database or file storage. Of course MySQL has a logging option, but that uses its own database. See: https://stackoverflow.com/questions/303994/log-all-queries-in-mysql?answertab=active#tab-top PDO doesn't log anything, of course, it's just an interface. – KIKO Software Jul 12 '18 at 06:03
  • If there isn't an internal counter of PHP may be I can try app based variables to create a counter? Anybody can help about that? – user1022786 Jul 13 '18 at 10:50
  • @KIKO Software : my comment was unclear i was referring to https://stackoverflow.com/questions/3247229/is-there-a-way-to-view-past-mysql-queries-with-phpmyadmin#3247676 and also using a plugin you can log specific query types in `PHP MyAdmin` but its accuracy is a different story. – Bobby Axe Jul 14 '18 at 02:39

0 Answers0