Current file: htdocs/lib/Zend/Db/Profiler/Query.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00%0.00%
0.00% 0 / 1
50.00%50.00%
50.00% 6 / 12 CRAP
59.38%59.38%
59.38% 19 / 32
 
Zend_Db_Profiler_Query
0.00%0.00%
0.00% 0 / 1
50.00%50.00%
50.00% 6 / 12
59.38%59.38%
59.38% 19 / 32
 __construct($query, $queryType)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 4 / 4
 __clone()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 4
 start()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 2 / 2
 end()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 2 / 2
 hasEnded()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 getQuery()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 getQueryType()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 bindParam($param, $variable)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 2 / 2
 bindParams(array $params)
100.00%100.00%
100.00% 1 / 1 3
100.00%100.00%
100.00% 8 / 8
 getQueryParams()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 getElapsedSecs()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 getStartedMicrotime()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3


       1                 : <?php                                                                                                  
       2                 : /**                                                                                                    
       3                 :  * Zend Framework                                                                                      
       4                 :  *                                                                                                     
       5                 :  * LICENSE                                                                                             
       6                 :  *                                                                                                     
       7                 :  * This source file is subject to the new BSD license that is bundled                                  
       8                 :  * with this package in the file LICENSE.txt.                                                          
       9                 :  * It is also available through the world-wide-web at this URL:                                        
      10                 :  * http://framework.zend.com/license/new-bsd                                                           
      11                 :  * If you did not receive a copy of the license and are unable to                                      
      12                 :  * obtain it through the world-wide-web, please send an email                                          
      13                 :  * to license@zend.com so we can send you a copy immediately.                                          
      14                 :  *                                                                                                     
      15                 :  * @category   Zend                                                                                    
      16                 :  * @package    Zend_Db                                                                                 
      17                 :  * @subpackage Profiler                                                                                
      18                 :  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)                
      19                 :  * @license    http://framework.zend.com/license/new-bsd     New BSD License                           
      20                 :  * @version    $Id: Query.php 23382 2010-11-18 22:50:50Z bittarman $                                   
      21                 :  */                                                                                                    
      22                 :                                                                                                        
      23                 :                                                                                                        
      24                 : /**                                                                                                    
      25                 :  * @category   Zend                                                                                    
      26                 :  * @package    Zend_Db                                                                                 
      27                 :  * @subpackage Profiler                                                                                
      28                 :  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)                
      29                 :  * @license    http://framework.zend.com/license/new-bsd     New BSD License                           
      30                 :  */                                                                                                    
      31                 : class Zend_Db_Profiler_Query                                                                           
      32                 : {                                                                                                      
      33                 :                                                                                                        
      34                 :     /**                                                                                                
      35                 :      * SQL query string or user comment, set by $query argument in constructor.                        
      36                 :      *                                                                                                 
      37                 :      * @var string                                                                                     
      38                 :      */                                                                                                
      39                 :     protected $_query = '';                                                                            
      40                 :                                                                                                        
      41                 :     /**                                                                                                
      42                 :      * One of the Zend_Db_Profiler constants for query type, set by $queryType argument in constructor.
      43                 :      *                                                                                                 
      44                 :      * @var integer                                                                                    
      45                 :      */                                                                                                
      46                 :     protected $_queryType = 0;                                                                         
      47                 :                                                                                                        
      48                 :     /**                                                                                                
      49                 :      * Unix timestamp with microseconds when instantiated.                                             
      50                 :      *                                                                                                 
      51                 :      * @var float                                                                                      
      52                 :      */                                                                                                
      53                 :     protected $_startedMicrotime = null;                                                               
      54                 :                                                                                                        
      55                 :     /**                                                                                                
      56                 :      * Unix timestamp with microseconds when self::queryEnd() was called.                              
      57                 :      *                                                                                                 
      58                 :      * @var integer                                                                                    
      59                 :      */                                                                                                
      60                 :     protected $_endedMicrotime = null;                                                                 
      61                 :                                                                                                        
      62                 :     /**                                                                                                
      63                 :      * @var array                                                                                      
      64                 :      */                                                                                                
      65                 :     protected $_boundParams = array();                                                                 
      66                 :                                                                                                        
      67                 :     /**                                                                                                
      68                 :      * @var array                                                                                      
      69                 :      */                                                                                                
      70                 :                                                                                                        
      71                 :     /**                                                                                                
      72                 :      * Class constructor.  A query is about to be started, save the query text ($query) and its        
      73                 :      * type (one of the Zend_Db_Profiler::* constants).                                                
      74                 :      *                                                                                                 
      75                 :      * @param  string  $query                                                                          
      76                 :      * @param  integer $queryType                                                                      
      77                 :      * @return void                                                                                    
      78                 :      */                                                                                                
      79                 :     public function __construct($query, $queryType)                                                    
      80                 :     {                                                                                                  
      81              15 :         $this->_query = $query;                                                                        
      82              15 :         $this->_queryType = $queryType;                                                                
      83                 :         // by default, and for backward-compatibility, start the click ticking                         
      84              15 :         $this->start();                                                                                
      85              15 :     }                                                                                                  
      86                 :                                                                                                        
      87                 :     /**                                                                                                
      88                 :      * Clone handler for the query object.                                                             
      89                 :      * @return void                                                                                    
      90                 :      */                                                                                                
      91                 :     public function __clone()                                                                          
      92                 :     {                                                                                                  
      93               0 :         $this->_boundParams = array();                                                                 
      94               0 :         $this->_endedMicrotime = null;                                                                 
      95               0 :         $this->start();                                                                                
      96               0 :     }                                                                                                  
      97                 :                                                                                                        
      98                 :     /**                                                                                                
      99                 :      * Starts the elapsed time click ticking.                                                          
     100                 :      * This can be called subsequent to object creation,                                               
     101                 :      * to restart the clock.  For instance, this is useful                                             
     102                 :      * right before executing a prepared query.                                                        
     103                 :      *                                                                                                 
     104                 :      * @return void                                                                                    
     105                 :      */                                                                                                
     106                 :     public function start()                                                                            
     107                 :     {                                                                                                  
     108              15 :         $this->_startedMicrotime = microtime(true);                                                    
     109              15 :     }                                                                                                  
     110                 :                                                                                                        
     111                 :     /**                                                                                                
     112                 :      * Ends the query and records the time so that the elapsed time can be determined later.           
     113                 :      *                                                                                                 
     114                 :      * @return void                                                                                    
     115                 :      */                                                                                                
     116                 :     public function end()                                                                              
     117                 :     {                                                                                                  
     118              15 :         $this->_endedMicrotime = microtime(true);                                                      
     119              15 :     }                                                                                                  
     120                 :                                                                                                        
     121                 :     /**                                                                                                
     122                 :      * Returns true if and only if the query has ended.                                                
     123                 :      *                                                                                                 
     124                 :      * @return boolean                                                                                 
     125                 :      */                                                                                                
     126                 :     public function hasEnded()                                                                         
     127                 :     {                                                                                                  
     128              15 :         return $this->_endedMicrotime !== null;                                                        
     129                 :     }                                                                                                  
     130                 :                                                                                                        
     131                 :     /**                                                                                                
     132                 :      * Get the original SQL text of the query.                                                         
     133                 :      *                                                                                                 
     134                 :      * @return string                                                                                  
     135                 :      */                                                                                                
     136                 :     public function getQuery()                                                                         
     137                 :     {                                                                                                  
     138               0 :         return $this->_query;                                                                          
     139                 :     }                                                                                                  
     140                 :                                                                                                        
     141                 :     /**                                                                                                
     142                 :      * Get the type of this query (one of the Zend_Db_Profiler::* constants)                           
     143                 :      *                                                                                                 
     144                 :      * @return integer                                                                                 
     145                 :      */                                                                                                
     146                 :     public function getQueryType()                                                                     
     147                 :     {                                                                                                  
     148               0 :         return $this->_queryType;                                                                      
     149                 :     }                                                                                                  
     150                 :                                                                                                        
     151                 :     /**                                                                                                
     152                 :      * @param string $param                                                                            
     153                 :      * @param mixed $variable                                                                          
     154                 :      * @return void                                                                                    
     155                 :      */                                                                                                
     156                 :     public function bindParam($param, $variable)                                                       
     157                 :     {                                                                                                  
     158               1 :         $this->_boundParams[$param] = $variable;                                                       
     159               1 :     }                                                                                                  
     160                 :                                                                                                        
     161                 :     /**                                                                                                
     162                 :      * @param array $param                                                                             
     163                 :      * @return void                                                                                    
     164                 :      */                                                                                                
     165                 :     public function bindParams(array $params)                                                          
     166                 :     {                                                                                                  
     167              15 :         if (array_key_exists(0, $params)) {                                                            
     168               1 :             array_unshift($params, null);                                                              
     169               1 :             unset($params[0]);                                                                         
     170               1 :         }                                                                                              
     171              15 :         foreach ($params as $param => $value) {                                                        
     172               1 :             $this->bindParam($param, $value);                                                          
     173              15 :         }                                                                                              
     174              15 :     }                                                                                                  
     175                 :                                                                                                        
     176                 :     /**                                                                                                
     177                 :      * @return array                                                                                   
     178                 :      */                                                                                                
     179                 :     public function getQueryParams()                                                                   
     180                 :     {                                                                                                  
     181               0 :         return $this->_boundParams;                                                                    
     182                 :     }                                                                                                  
     183                 :                                                                                                        
     184                 :     /**                                                                                                
     185                 :      * Get the elapsed time (in seconds) that the query ran.                                           
     186                 :      * If the query has not yet ended, false is returned.                                              
     187                 :      *                                                                                                 
     188                 :      * @return float|false                                                                             
     189                 :      */                                                                                                
     190                 :     public function getElapsedSecs()                                                                   
     191                 :     {                                                                                                  
     192               0 :         if (null === $this->_endedMicrotime) {                                                         
     193               0 :             return false;                                                                              
     194                 :         }                                                                                              
     195                 :                                                                                                        
     196               0 :         return $this->_endedMicrotime - $this->_startedMicrotime;                                      
     197                 :     }                                                                                                  
     198                 :                                                                                                        
     199                 :     /**                                                                                                
     200                 :      * Get the time (in seconds) when the profiler started running.                                    
     201                 :      *                                                                                                 
     202                 :      * @return bool|float                                                                              
     203                 :      */                                                                                                
     204                 :     public function getStartedMicrotime()                                                              
     205                 :     {                                                                                                  
     206               0 :         if(null === $this->_startedMicrotime) {                                                        
     207               0 :             return false;                                                                              
     208                 :         }                                                                                              
     209                 :                                                                                                        
     210               0 :         return $this->_startedMicrotime;                                                               
     211                 :     }                                                                                                  
     212                 : }                                                                                                      
     213                 :                                                                                                        

Generated by PHP_CodeCoverage 1.0.4 using PHP 5.3.4 and PHPUnit 3.5.13 at Tue Jul 5 9:07:16 UTC 2011.