Tabla de Contenidos

Tema anterior

< Class Phalcon\Db\Index

Próximo tema

Class Phalcon\Db\Profiler\Item >

Esta página

Class Phalcon\Db\Profiler

Instances of Phalcon\Db can generate execution profiles on SQL statements sent to the relational database. Profiled information includes execution time in miliseconds. This helps you to identify bottlenecks in your applications.


$profiler = new Phalcon\Db\Profiler();

//Set the connection profiler

$sql = "SELECT buyer_name, quantity, product_name
FROM buyers LEFT JOIN products ON";

//Execute a SQL statement

//Get the last profile in the profiler
$profile = $profiler->getLastProfile();

echo "SQL Statement: ", $profile->getSQLStatement(), "\n";
echo "Start Time: ", $profile->getInitialTime(), "\n";
echo "Final Time: ", $profile->getFinalTime(), "\n";
echo "Total Elapsed Time: ", $profile->getTotalElapsedSeconds(), "\n";


public __construct ()

Phalcon\Db\Profiler constructor

public Phalcon\Db\Profiler startProfile (string $sqlStatement)

Starts the profile of a SQL sentence

public Phalcon\Db\Profiler stopProfile ()

Stops the active profile

public integer getNumberTotalStatements ()

Returns the total number of SQL statements processed

public double getTotalElapsedSeconds ()

Returns the total time in seconds spent by the profiles

public Phalcon\Db\Profiler\Item [] getProfiles ()

Returns all the processed profiles

public Phalcon\Db\Profiler reset ()

Resets the profiler, cleaning up all the profiles

public Phalcon\Db\Profiler\Item getLastProfile ()

Returns the last profile executed in the profiler