Created
January 25, 2016 11:19
-
-
Save whitewhidow/167a873fb851990ea883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Doctrine\DBAL\Logging; | |
class EchoSQLLogger implements SQLLogger | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function startQuery($sql, array $params = null, array $types = null) | |
{ | |
$sprintable = str_replace('?', '%s', $sql); | |
if (is_array($params)) { | |
foreach ($params as $key => $param) { | |
if ($param instanceof \DateTime) { | |
$params[$key] = $param->format('d-m-Y H:i:s'); | |
} | |
} | |
} | |
$clean = vsprintf($sprintable , $params).PHP_EOL; | |
file_put_contents('/tmp/queriess.txt', $clean."\n", FILE_APPEND | LOCK_EX); | |
if ($params) { | |
//var_dump($params); | |
} | |
if ($types) { | |
//var_dump($types); | |
} | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function stopQuery() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment