stefangabos/Zebra_Database

Debug information

userc479 opened this issue · 3 comments

Basically, I'm using Zebra Database to perform multiple database queries - I would like it to show more than one debug information for every query performed but if I request three queries using the function below - it only shows 2 successful queries - first one for charset and first query the debugger has caught - anymore than one it doesn't show it - any help here please? Thanks :)

//Function to connect to database
        function pam_functions_mysql_query($value)
        {
            require_once pam_definition_path_assets_components."zebra_database/Zebra_Database.php";
            
            $db = new Zebra_Database();

            $db ->connect(pam_definition_mysql_connection_hostname,pam_definition_mysql_connection_username, pam_definition_mysql_connection_password,pam_definition_mysql_connection_database_name);
            
            $db->set_charset();
            if (pam_definition_debug_mysql_view_errors===true)
            {
                $db->debug;                
            }else{
                $db->debug=false;
            }
            
            $results = $db->query($value);
            $db->close();
            return $results;
            }

Since you are instantiating Zebra_Database inside a function and as a local variable, only those queries run while inside that function are shown. Zebra_Database should be globally available

I'm doing it inside a function so I don't follow the DRY approach but also to keep the MYSQL connections closed as much as possible to avoid too many mysql connection issues. The above function still processes the other queries after twice but it's the debug information that doesn't seem to output the query information after twice other than query errors. Just don't understand why it's only showing twice :(

It shows only the results of the first function, which only runs 2 queries. If you look into the generated HTML, you'll see that there are as many debugging interfaces as you have functions but because they all share the same ID's, you can interact only with the first one.

MySQL connections are automatically closed when a PHP script ends. It is true that (at least from my experience) that connecting and closing connections many time per the duration of the script does not affect performance significantly but it is much easier to have one instance of Zebra_Database which you close at the end of your script