class_mcPDOLogger.inc.php 1.11 KB
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of class_mcPDOLogger
 *
 * @author Frederick <frederick at mensch.coop>
 */
class mcPDOLogger {
	private static $Messages = array();
	public static function add($param_order, array $param_bindValueArray=null, $param_count_result=false, $param_optional='') {
		mcPDOLogger::$Messages[] = array(
			'order' => $param_order, 
			'bindValue' => $param_bindValueArray,
			'optional' => $param_optional,
			'count_result' => $param_count_result,
		);
	}

	public static function getMessagesAsText() {
		$MessageAsText = '';
		foreach(mcPDOLogger::$Messages as $index =>  $message) {
			arsort($message['bindValue']);
			foreach($message['bindValue'] as $string => $value) {
				if(is_string($value)) {
					$value = "'".$value."'";
				}
				$message['order'] = str_replace($string, $value, $message['order']);
			}			
			
			
			$MessageAsText .= "\n".$index.":\t".trim($message['order'])."\n\t\tcount:\t".$message['count_result']."\n";
		}
		
		mcPDOLogger::$Messages = array();
		return $MessageAsText;
	}

}

?>