DebugConnection Class Reference

Inheritance diagram for DebugConnection:

Connection

List of all members.

Public Member Functions

 setLogger ($logger)
 Sets a Logger class (e.g.
 getNumQueriesExecuted ()
 Returns the number of queries executed on this connection so far.
 getLastExecutedQuery ()
 Returns the last query executed on this connection.
 connect ($dsninfo, $flags=0)
 connect()
 getDatabaseInfo ()
 getIdGenerator ()
 isConnected ()
 prepareStatement ($sql)
 createStatement ()
 applyLimit (&$sql, $offset, $limit)
 close ()
 executeQuery ($sql, $fetchmode=null)
 executeUpdate ($sql)
 getUpdateCount ()
 prepareCall ($sql)
 getResource ()
 getDSN ()
 getFlags ()
 begin ()
 commit ()
 rollback ()
 setAutoCommit ($bit)
 getAutoCommit ()

Private Member Functions

 log ($msg)
 Private function that logs message using specified logger (if provided).

Private Attributes

 $childConnection = null
 $numQueriesExecuted = 0
 $lastExecutedQuery = ''
 $logger


Detailed Description

Definition at line 27 of file DebugConnection.php.


Member Function Documentation

DebugConnection::applyLimit ( &$  sql,
offset,
limit 
)

See also:
Connection::applyLimit()

Implements Connection.

Definition at line 135 of file DebugConnection.php.

References log().

00136   {
00137     $this->log("applyLimit(): $sql, offset: $offset, limit: $limit");
00138     return $this->childConnection->applyLimit($sql, $offset, $limit);
00139   }

DebugConnection::begin (  ) 

See also:
Connection::begin()

Implements Connection.

Definition at line 216 of file DebugConnection.php.

References log().

00217   {
00218     $this->log("Beginning transaction.");
00219     return $this->childConnection->begin();
00220   }

DebugConnection::close (  ) 

See also:
Connection::close()

Implements Connection.

Definition at line 144 of file DebugConnection.php.

References log().

00145   {
00146     $this->log("close(): Closing connection.");
00147     return $this->childConnection->close();
00148   }

DebugConnection::commit (  ) 

See also:
Connection::commit()

Implements Connection.

Definition at line 225 of file DebugConnection.php.

References log().

00226   {
00227     $this->log("Committing transaction.");
00228     return $this->childConnection->commit();
00229   }

DebugConnection::connect ( dsninfo,
flags = 0 
)

connect()

Implements Connection.

Definition at line 76 of file DebugConnection.php.

References Creole::getDriver(), Creole::import(), and log().

00077   {
00078     if (!($driver = Creole::getDriver($dsninfo['phptype']))) {
00079       throw new SQLException("No driver has been registered to handle connection type: $type");
00080     }   
00081     $connectionClass = Creole::import($driver);
00082     $this->childConnection = new $connectionClass();
00083     $this->log("connect(): DSN: ". var_export($dsninfo, true) . ", FLAGS: " . var_export($flags, true));
00084     return $this->childConnection->connect($dsninfo, $flags);
00085   }

DebugConnection::createStatement (  ) 

See also:
Connection::createStatement()

Implements Connection.

Definition at line 125 of file DebugConnection.php.

00126   {
00127     $obj = $this->childConnection->createStatement();
00128     $objClass = get_class($obj);    
00129     return new $objClass($this);
00130   }

DebugConnection::executeQuery ( sql,
fetchmode = null 
)

See also:
Connection::executeQuery()

Implements Connection.

Definition at line 153 of file DebugConnection.php.

References log().

00154   {
00155     $this->log("executeQuery(): $sql");
00156     $this->lastExecutedQuery = $sql;
00157     $this->numQueriesExecuted++;
00158     return $this->childConnection->executeQuery($sql, $fetchmode);  
00159   }

DebugConnection::executeUpdate ( sql  ) 

See also:
Connection::executeUpdate()

Implements Connection.

Definition at line 164 of file DebugConnection.php.

References log().

00165   {
00166     $this->log("executeUpdate(): $sql");
00167     $this->lastExecutedQuery = $sql;
00168     $this->numQueriesExecuted++;
00169     return $this->childConnection->executeUpdate($sql); 
00170   }

DebugConnection::getAutoCommit (  ) 

See also:
Connection::getAutoCommit()

Implements Connection.

Definition at line 252 of file DebugConnection.php.

00253   {
00254     return $this->childConnection->getAutoCommit();
00255   }

DebugConnection::getDatabaseInfo (  ) 

See also:
Connection::getDatabaseInfo()

Implements Connection.

Definition at line 90 of file DebugConnection.php.

00091   {
00092     return $this->childConnection->getDatabaseInfo();
00093   }

DebugConnection::getDSN (  ) 

See also:
Connection::connect()

Implements Connection.

Definition at line 200 of file DebugConnection.php.

00201   {
00202     return $this->childConnection->getDSN();
00203   }

DebugConnection::getFlags (  ) 

See also:
Connection::getFlags()

Implements Connection.

Definition at line 208 of file DebugConnection.php.

00209   {
00210     return $this->childConnection->getFlags();
00211   }

DebugConnection::getIdGenerator (  ) 

See also:
Connection::getIdGenerator()

Implements Connection.

Definition at line 98 of file DebugConnection.php.

00099   {
00100     return $this->childConnection->getIdGenerator();
00101   }

DebugConnection::getLastExecutedQuery (  ) 

Returns the last query executed on this connection.

Returns:
string

Definition at line 68 of file DebugConnection.php.

00069   {
00070     return $this->lastExecutedQuery;
00071   }

DebugConnection::getNumQueriesExecuted (  ) 

Returns the number of queries executed on this connection so far.

Returns:
int

Definition at line 58 of file DebugConnection.php.

00059   {
00060     return $this->numQueriesExecuted;
00061   }

DebugConnection::getResource (  ) 

See also:
Connection::getResource()

Implements Connection.

Definition at line 192 of file DebugConnection.php.

00193   {
00194     return $this->childConnection->getResource();
00195   }

DebugConnection::getUpdateCount (  ) 

See also:
Connection::getUpdateCount()

Implements Connection.

Definition at line 175 of file DebugConnection.php.

00176   {
00177     return $this->childConnection->getUpdateCount();
00178   }

DebugConnection::isConnected (  ) 

See also:
Connection::isConnected()

Implements Connection.

Definition at line 106 of file DebugConnection.php.

00107   {
00108     return $this->childConnection->isConnected();
00109   }

DebugConnection::log ( msg  )  [private]

Private function that logs message using specified logger (if provided).

Parameters:
string $msg Message to log.

Definition at line 261 of file DebugConnection.php.

Referenced by applyLimit(), begin(), close(), commit(), connect(), executeQuery(), executeUpdate(), prepareCall(), prepareStatement(), rollback(), and setAutoCommit().

00262   {
00263     if ($this->logger) {
00264       $this->logger->log($msg);
00265     }
00266   }

DebugConnection::prepareCall ( sql  ) 

See also:
Connection::prepareCall()

Implements Connection.

Definition at line 183 of file DebugConnection.php.

References log().

00184   {
00185     $this->log("prepareCall(): $sql");
00186     return $this->childConnection->prepareCall($sql);
00187   }

DebugConnection::prepareStatement ( sql  ) 

See also:
Connection::prepareStatement()

Implements Connection.

Definition at line 114 of file DebugConnection.php.

References log().

00115   {
00116     $this->log("prepareStatement(): $sql");
00117     $obj = $this->childConnection->prepareStatement($sql);
00118     $objClass = get_class($obj);    
00119     return new $objClass($this, $sql);
00120   }

DebugConnection::rollback (  ) 

See also:
Connection::rollback()

Implements Connection.

Definition at line 234 of file DebugConnection.php.

References log().

00235   {
00236     $this->log("Rolling back transaction.");
00237     return $this->childConnection->rollback();
00238   }

DebugConnection::setAutoCommit ( bit  ) 

See also:
Connection::setAutoCommit()

Implements Connection.

Definition at line 243 of file DebugConnection.php.

References log().

00244   {
00245     $this->log("Setting autocommit to: " . var_export($bit, true));
00246     return $this->childConnection->setAutoCommit($bit);
00247   }

DebugConnection::setLogger ( logger  ) 

Sets a Logger class (e.g.

PEAR Log) to use for logging. The logger class must have a log() method. All messages are logged at default log level.

Parameters:
object $logger

Definition at line 48 of file DebugConnection.php.

References $logger.

00049   {
00050     $this->logger = $logger;
00051   }


Member Data Documentation

DebugConnection::$childConnection = null [private]

Definition at line 30 of file DebugConnection.php.

DebugConnection::$lastExecutedQuery = '' [private]

Definition at line 36 of file DebugConnection.php.

DebugConnection::$logger [private]

Definition at line 41 of file DebugConnection.php.

Referenced by setLogger().

DebugConnection::$numQueriesExecuted = 0 [private]

Definition at line 33 of file DebugConnection.php.


The documentation for this class was generated from the following file:

Generated on Wed May 6 23:10:49 2009 for fareofficelib by  doxygen 1.5.8