Blame view

class_mcPDOLogger.inc.php 1.16 KB
1
<?php
sn committed
2 3 4
/** 
 * @copyright (c) 2014, netz.coop eG
 */
5 6 7 8 9 10 11 12 13 14 15 16 17

/*
 * 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();
18
	public static function add($param_order, array $param_bindValueArray=null, $param_count_result=false, $param_optional='') {
19 20 21
		mcPDOLogger::$Messages[] = array(
			'order' => $param_order, 
			'bindValue' => $param_bindValueArray,
22 23
			'optional' => $param_optional,
			'count_result' => $param_count_result,
24 25 26 27 28
		);
	}

	public static function getMessagesAsText() {
		$MessageAsText = '';
29 30 31 32 33 34 35 36 37 38 39
		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";
40 41 42 43 44 45 46 47 48
		}
		
		mcPDOLogger::$Messages = array();
		return $MessageAsText;
	}

}

?>