2008年9月17日星期三

Re: [fw-db] Zend_Db_Profiler_Firebug - query time fix

Thank you for reporting this. The "," in the float value must be due to your different locale setting.

I like the addition of the number of queries and total time as well. However I would not append it to the end.

Lets insert it into the label wherever we find certain placeholders.

'All DB Queries (%totalCount% - %totalDuration%)

What do you think?

Christoph



Diabl0 wrote:
Hi

    I'm writing here as i don't have create issue permision on zf issue
tracker.

    *Problem*

    Zend_Db_Profiler_Firebug. Query times are passed to firebug as float
without quoting which results as 4 cols table JSON in headers. Eg.:


[0,00011,"SET CHARACTER SET utf8",null]
  ^     ^

    result is broken (shifted) table in firebug. eg:

Time | Event | Parameters             | [null] |
0    | 11    | SET CHARACTER SET utf8 | [null] |

instead of expected:

Time    | Event                  | Parameters |
0,00011 | SET CHARACTER SET utf8 | [null]     |



    *Solution*


Forcing ZF to pass query time as string instead of original float:

Zend_Db_Profiler_Firebug::queryEnd() line 128

_original line_:
        $this->_message->addRow(array(round($profile->getElapsedSecs(),5),
                                      $profile->getQuery(),

($params=$profile->getQueryParams())?$params:null));


_fixed line_:

        $this->_message->addRow(array( (string) round(
$profile->getElapsedSecs(), 5),
                                      $profile->getQuery(),

($params=$profile->getQueryParams())?$params:null));


    *Additional enhancement*

And, my small enhancement of updateMessageLabel() function to add total
queries count in message label:


Zend_Db_Profiler_Firebug::updateMessageLabel() line 145:

_original:_
$this->_message->setLabel($this->_label . ' (' .
round($this->_totalElapsedTime,5) . ' sec)');

_changed (added query count):_

$this->_message->setLabel($this->_label . ' (' .
$this->getTotalNumQueries() .' - ' . round($this->_totalElapsedTime,5) .
' sec)');



没有评论: