";
$r[] = "Component : ".$record->getTable()->getComponentName();
$r[] = "ID : ".$record->getID();
$r[] = "References : ".count($record->getReferences());
$r[] = "State : ".Doctrine_Lib::getRecordStateAsString($record->getState());
$r[] = "OID : ".$record->getOID();
$r[] = "";
return implode("\n",$r)."
";
}
/**
* getStateAsString
* returns a given session state as string
* @param integer $state session state
*/
public static function getSessionStateAsString($state) {
switch($state):
case Doctrine_Session::STATE_OPEN:
return "open";
break;
case Doctrine_Session::STATE_CLOSED:
return "closed";
break;
case Doctrine_Session::STATE_BUSY:
return "busy";
break;
case Doctrine_Session::STATE_ACTIVE:
return "active";
break;
endswitch;
}
/**
* returns a string representation of Doctrine_Session object
* @param Doctrine_Session $session
* @return string
*/
public static function getSessionAsString(Doctrine_Session $session) {
$r[] = "
"; $r[] = "Doctrine_Session object"; $r[] = "State : ".Doctrine_Lib::getSessionStateAsString($session->getState()); $r[] = "Open Transactions : ".$session->getTransactionLevel(); $r[] = "Open Factories : ".$session->count(); $sum = 0; $rsum = 0; $csum = 0; foreach($session->getTables() as $objTable) { if($objTable->getCache() instanceof Doctrine_Cache_File) { $sum += array_sum($objTable->getCache()->getStats()); $rsum += $objTable->getRepository()->count(); $csum += $objTable->getCache()->count(); } } $r[] = "Cache Hits : ".$sum." hits "; $r[] = "Cache : ".$csum." objects "; $r[] = "Repositories : ".$rsum." objects "; $queries = false; if($session->getDBH() instanceof Doctrine_DB) { $handler = "Doctrine Database Handler"; $queries = count($session->getDBH()->getQueries()); $sum = array_sum($session->getDBH()->getExecTimes()); } elseif($session->getDBH() instanceof PDO) { $handler = "PHP Native PDO Driver"; } else $handler = "Unknown Database Handler"; $r[] = "DB Handler : ".$handler; if($queries) { $r[] = "Executed Queries : ".$queries; $r[] = "Sum of Exec Times : ".$sum; } $r[] = ""; return implode("\n",$r)."
"; $r[] = "Component : ".$table->getComponentName(); $r[] = "Table : ".$table->getTableName(); $r[] = "Repository : ".$table->getRepository()->count()." objects"; if($table->getCache() instanceof Doctrine_Cache_File) { $r[] = "Cache : ".$table->getCache()->count()." objects"; $r[] = "Cache hits : ".array_sum($table->getCache()->getStats())." hits"; } $r[] = ""; return implode("\n",$r)."
"; $r[] = get_class($collection); foreach($collection as $key => $record) { $r[] = "Key : ".$key." ID : ".$record->getID(); } $r[] = ""; return implode("\n",$r); } } ?>