To use an array of SQL query in FIREPHP::TABLE

53 views
Skip to first unread message

Pmithrandir

unread,
Sep 2, 2008, 11:30:09 AM9/2/08
to FirePHP
Hello

In my application, I have a debug mode. In this mode, I log every
query in a PHP table.
Actualy, I screen this array on the back of myu webpage but I would
like to screen on fire php.
I have write this code :
fb(array(
$nbQuery requetes SQL en ".$TIME_QUERY." secondes",
array(
array('REQUETE','Temps','Fichier', 'Ligne', 'callback',
'microtime', "pile d'appel"),
$TAB_REQUETES
)
),FirePHP::TABLE);

The var $TAB_REQUETES is like to :
Array
(
[0] => Array
(
[REQUETE] => SELECT Id_version, NomPackClient,
NomPackCommun, Numero_version FROM Version_PF A JOIN ( SELECT
MAX(Id_version) AS maxIdVersion FROM Version_PF) B ON A.Id_version =
B.maxIdVersion
[TIME] => 0.00268483161926
[FILE] => C:\xampp\htdocs\BLUE_MEDI_V6_6\Module_LIB
\LIB_declarations.php
[LINE] => 25
[CALLBACK] => require_once('C:\\xampp\\htdocs\
\BLUE_MEDI_V6_6\\Module_LIB\\LIB_declarations.php')
[MICROTIME] => 0.05337900 1220369108
)
[1] => Array
(
[REQUETE] => SELECT Id, Id_etab, Services, Instances,
Glossaire, Mots_cles, Modeles_projets, Libelle_phases, Libelle_taches,
Particip_ext,Types_projets, Themes_docs, Profils, Postes,
Postes_utilisation,Types_lieux, Lieux, Types_interventions,
Fournisseurs, Prestations_externes,Fonctions,
gestion_materiel,risquesFROM Param_general
[TIME] => 0.0018150806427
[FILE] => C:\xampp\htdocs\BLUE_MEDI_V6_6\Module_LIB
\LIB_declarations.php
[LINE] => 158
[CALLBACK] => require_once('C:\\xampp\\htdocs\
\BLUE_MEDI_V6_6\\Module_LIB\\LIB_declarations.php')
[MICROTIME] => 0.08301100 1220369108
)
)
And many more query...

Can I use this array in FIREPHP ?

Thanks

Pierre

Christoph Dorn

unread,
Sep 2, 2008, 12:45:51 PM9/2/08
to FirePHP
Should be no problem. All you have to do is drop the column keys in
your data. i.e. REQUETE, TIME, FILE, .... And make sure the order of
the values always correspond to the order of the header columns.

Sample table:


fb(array('2 SQL queries took 0.06 seconds',
array(
array('SQL Statement','Time','Result'),
array('SELECT * FROM Foo','0.02',array('row1','row2')),
array('SELECT * FROM Bar','0.04',array('row1','row2'))
)
),FirePHP::TABLE);

Christoph

Pmithrandir

unread,
Sep 3, 2008, 4:40:39 AM9/3/08
to FirePHP

I don't understand what you want me to make.

In your exemple, I have one array by line.

Or in my case, I have one array who have all my data.

If i drop the column key, i will have an array without any information
to help the comprehension ?

I have try to transform your sample :
$mytab = array(
array('SQL Statement','Time','Result'),
array('SELECT * FROM Foo','0.02',array('row1','row2')),
array('SELECT * FROM Bar','0.04',array('row1','row2')));
fb(array('2 SQL queries took 0.06 seconds',
array(

$mytab
)
),FirePHP::TABLE);

but it screen 3 columns with one column by array.

$mytab = array(
array('SELECT * FROM Foo','0.02',array('row1','row2')),
array('SELECT * FROM Bar','0.04',array('row1','row2')));
fb(array('2 SQL queries took 0.06 seconds',
array(
array('SQL Statement','Time','Result'),
$mytab
)
),FirePHP::TABLE);
And this code screen 3 column with the two first content are array.

Have you another method to make this script ?

Pierre

Pmithrandir

unread,
Sep 3, 2008, 4:40:52 AM9/3/08
to FirePHP

I don't understand what you want me to make.

In your exemple, I have one array by line.

Or in my case, I have one array who have all my data.

If i drop the column key, i will have an array without any information
to help the comprehension ?

I have try to transform your sample :
$mytab = array(
array('SQL Statement','Time','Result'),
array('SELECT * FROM Foo','0.02',array('row1','row2')),
array('SELECT * FROM Bar','0.04',array('row1','row2')));
fb(array('2 SQL queries took 0.06 seconds',
array(

$mytab
)
),FirePHP::TABLE);

but it screen 3 columns with one column by array.

$mytab = array(
array('SELECT * FROM Foo','0.02',array('row1','row2')),
array('SELECT * FROM Bar','0.04',array('row1','row2')));
fb(array('2 SQL queries took 0.06 seconds',
array(
array('SQL Statement','Time','Result'),

Christoph Dorn

unread,
Sep 3, 2008, 4:49:04 AM9/3/08
to FirePHP

> If i drop the column key, i will have an array without any information
> to help the comprehension ?

Right. FirePHP puts it back together with the first row which is the
header.
You can cleanup your $TAB_REQUETES array with the following code
before passing it to the fb() method.

for( $i=0 ; $i<count($TAB_REQUETES) ; $i++ ) {
$TAB_REQUETES[$i] = array_values($TAB_REQUETES[$i]);
}

Christoph
Reply all
Reply to author
Forward
0 new messages