API Documentation

Db/Profiler.php

Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Db
subpackage
Profiler
version
$Id: Profiler.php 20096 2010-01-06 02:05:09Z bkarwin $
Classes
Zend_Db_Profiler

Description

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Zend_Db_Profiler

category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Db
subpackage
Profiler
Constants
CONNECT
QUERY
INSERT
UPDATE
DELETE
SELECT
TRANSACTION
STORED
IGNORED
Properties
$_queryProfiles
$_enabled
$_filterElapsedSecs
$_filterTypes
Methods
__construct
setEnabled
getEnabled
setFilterElapsedSecs
getFilterElapsedSecs
setFilterQueryType
getFilterQueryType
clear
queryClone
queryStart
queryEnd
getQueryProfile
getQueryProfiles
getTotalElapsedSecs
getTotalNumQueries
getLastQueryProfile

Description

Constants

CONNECT

 CONNECT = '1'

A connection operation or selecting a database.

Details

value
1

QUERY

 QUERY = '2'

Any general database query that does not fit into the other constants.

Details

value
2

INSERT

 INSERT = '4'

Adding new data to the database, such as SQL's INSERT.

Details

value
4

UPDATE

 UPDATE = '8'

Updating existing information in the database, such as SQL's UPDATE.

Details

value
8

DELETE

 DELETE = '16'

An operation related to deleting data in the database, such as SQL's DELETE.

Details

value
16

SELECT

 SELECT = '32'

Retrieving information from the database, such as SQL's SELECT.

Details

value
32

TRANSACTION

 TRANSACTION = '64'

Transactional operation, such as start transaction, commit, or rollback.

Details

value
64

STORED

 STORED = 'stored'

Inform that a query is stored (in case of filtering)

Details

value
stored

IGNORED

 IGNORED = 'ignored'

Inform that a query is ignored (in case of filtering)

Details

value
ignored

Properties

$_enabled

boolean $_enabled = 'false'

Stores enabled state of the profiler. If set to False, calls to queryStart() will simply be ignored.

Details

$_enabled
boolean
visibility
protected
default
false
final
false
static
false

$_filterElapsedSecs

integer $_filterElapsedSecs = 'null'

Stores the number of seconds to filter. NULL if filtering by time is disabled. If an integer is stored here, profiles whose elapsed time is less than this value in seconds will be unset from the self::$_queryProfiles array.

Details

$_filterElapsedSecs
integer
visibility
protected
default
null
final
false
static
false

$_filterTypes

integer $_filterTypes = 'null'

Logical OR of any of the filter constants. NULL if filtering by query type is disable. If an integer is stored here, it is the logical OR of any of the query type constants. When the query ends, if it is not one of the types specified, it will be unset from the self::$_queryProfiles array.

Details

$_filterTypes
integer
visibility
protected
default
null
final
false
static
false

$_queryProfiles

array $_queryProfiles = 'array'

Array of Zend_Db_Profiler_Query objects.

Details

$_queryProfiles
array
visibility
protected
default
array
final
false
static
false

Methods

__construct

__construct( boolean $enabled = false ) : void

Class constructor. The profiler is disabled by default unless it is specifically enabled by passing in $enabled here or calling setEnabled().

Arguments
$enabled
boolean
Details
visibility
public
final
false
static
false

clear

clear( ) : Zend_Db_Profiler

Clears the history of any past query profiles. This is relentless and will even clear queries that were started and may not have been marked as ended.

Output
Zend_Db_Profiler
Provides a fluent interface
Details
visibility
public
final
false
static
false

getEnabled

getEnabled( ) : boolean

Get the current state of enable. If True is returned, the profiler is enabled.

Output
boolean
Details
visibility
public
final
false
static
false

getFilterElapsedSecs

getFilterElapsedSecs( ) : integer|null

Returns the minimum number of seconds for saving query profiles, or null if query profiles are saved regardless of elapsed time.

Output
integer|null
Details
visibility
public
final
false
static
false

getFilterQueryType

getFilterQueryType( ) : integer|null

Returns the types of query profiles saved, or null if queries are saved regardless of their types.

Output
integer|null
Details
visibility
public
final
false
static
false
see
Zend_Db_Profiler::setFilterQueryType()

getLastQueryProfile

getLastQueryProfile( ) : Zend_Db_Profiler_Query|false

Get the Zend_Db_Profiler_Query object for the last query that was run, regardless if it has ended or not. If the query has not ended, its end time will be null. If no queries have been profiled, false is returned.

Output
Zend_Db_Profiler_Query|false
Details
visibility
public
final
false
static
false

getQueryProfile

getQueryProfile( integer $queryId ) : Zend_Db_Profiler_Query

Get a profile for a query. Pass it the same handle that was returned by queryStart() and it will return a Zend_Db_Profiler_Query object.

Arguments
$queryId
integer
Details
visibility
public
final
false
static
false
throws

getQueryProfiles

getQueryProfiles( integer $queryType = null, boolean $showUnfinished = false ) : array|false

Get an array of query profiles (Zend_Db_Profiler_Query objects). If $queryType is set to one of the Zend_Db_Profiler::* constants then only queries of that type will be returned. Normally, queries that have not yet ended will not be returned unless $showUnfinished is set to True. If no queries were found, False is returned. The returned array is indexed by the query profile handles.

Arguments
$queryType
integer
$showUnfinished
boolean
Output
array|false
Details
visibility
public
final
false
static
false

getTotalElapsedSecs

getTotalElapsedSecs( integer $queryType = null ) : float

Get the total elapsed time (in seconds) of all of the profiled queries.

Only queries that have ended will be counted. If $queryType is set to one or more of the Zend_Db_Profiler::* constants, the elapsed time will be calculated only for queries of the given type(s).

Arguments
$queryType
integer
OPTIONAL
Output
float
Details
visibility
public
final
false
static
false

getTotalNumQueries

getTotalNumQueries( integer $queryType = null ) : integer

Get the total number of queries that have been profiled. Only queries that have ended will be counted. If $queryType is set to one of the Zend_Db_Profiler::* constants, only queries of that type will be counted.

Arguments
$queryType
integer
OPTIONAL
Output
integer
Details
visibility
public
final
false
static
false

queryClone

queryClone(  $query ) : integer

Arguments
$query
Output
integer
or null
Details
visibility
public
final
false
static
false

queryEnd

queryEnd( integer $queryId ) : void

Ends a query. Pass it the handle that was returned by queryStart().

This will mark the query as ended and save the time.

Arguments
$queryId
integer
Details
visibility
public
final
false
static
false
throws

queryStart

queryStart( string $queryText, integer $queryType = null ) : integer|null

Starts a query. Creates a new query profile object (Zend_Db_Profiler_Query) and returns the "query profiler handle". Run the query, then call queryEnd() and pass it this handle to make the query as ended and record the time. If the profiler is not enabled, this takes no action and immediately returns null.

Arguments
$queryText
string
SQL statement
$queryType
integer
OPTIONAL Type of query, one of the Zend_Db_Profiler::* constants
Output
integer|null
Details
visibility
public
final
false
static
false

setEnabled

setEnabled( boolean $enable ) : Zend_Db_Profiler

Enable or disable the profiler. If $enable is false, the profiler is disabled and will not log any queries sent to it.

Arguments
$enable
boolean
Output
Zend_Db_Profiler
Provides a fluent interface
Details
visibility
public
final
false
static
false

setFilterElapsedSecs

setFilterElapsedSecs( integer $minimumSeconds = null ) : Zend_Db_Profiler

Sets a minimum number of seconds for saving query profiles. If this is set, only those queries whose elapsed time is equal or greater than $minimumSeconds will be saved. To save all queries regardless of elapsed time, set $minimumSeconds to null.

Arguments
$minimumSeconds
integer
OPTIONAL
Output
Zend_Db_Profiler
Provides a fluent interface
Details
visibility
public
final
false
static
false

setFilterQueryType

setFilterQueryType( integer $queryTypes = null ) : Zend_Db_Profiler

Sets the types of query profiles to save. Set $queryType to one of the Zend_Db_Profiler::* constants to only save profiles for that type of query. To save more than one type, logical OR them together. To save all queries regardless of type, set $queryType to null.

Arguments
$queryTypes
integer
OPTIONAL
Output
Zend_Db_Profiler
Provides a fluent interface
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.