I can't seem to get the Zend_Profiler to work as I would have expected. I
copied, line for line (adding in one little twist), what's on the ZFW site,
but every time it comes across as blank. Well, it says it did 30 queries,
but shows me none of them. Here's an example of the email:

Executed 30 queries in 0.17027044296265 seconds
>
> Average query length: 0.0056756814320882 seconds
>
> Queries per second: 176.19029749386
>
> Longest query length: 0.066329002380371
>
> Longest query:
>
> connect
>
>
>
> Query list:
>
> connect
>

30 queries, but nothing query list? It seems very odd. Here's my code:

       $profiler = My_Db::getInstance()->getProfiler();
       $totalTime = $profiler->getTotalElapsedSecs();
       $queryCount = $profiler->getTotalNumQueries();
       $longestTime = 0;
       $longestQuery = null;
       $queryList = null;

       foreach ( $profiler->getQueryProfiles() as $query ) {
          $queryList .= $query->getQuery() . "\n";
          if ( $query->getElapsedSecs() > $longestTime ) {
             $longestTime = $query->getElapsedSecs();
             $longestQuery = $query->getQuery();
          }
       }

       $tmp = 'Executed ' . $queryCount . ' queries in ' . $totalTime . '
seconds' . "\n";
       $tmp .= 'Average query length: ' . $totalTime / $queryCount . '
seconds' . "\n";
       $tmp .= 'Queries per second: ' . $queryCount / $totalTime . "\n";
       $tmp .= 'Longest query length: ' . $longestTime . "\n";
       $tmp .= "Longest query: \n" . $longestQuery . "\n\n";
       $tmp .= "Query list: \n" . $longestQuery . "\n\n";

Now, I am running transactions with this, but not sure if that's affecting
or not:

      $dbh = My_Db::getInstance(  );
      $dbh->getProfiler()->setEnabled( true );
      $dbh->beginTransaction();

I have attempted to call the profiler before ->commit() and after ->commit()
each with the same result. And empty email....

Am I doing something wrong here? The profiler seems like a powerful tool in
DB optimization, but it's not giving me any data.

-- 
Philip
[EMAIL PROTECTED]
http://www.gpcentre.net/

Reply via email to