Skip to content

Instantly share code, notes, and snippets.

@whitewhidow
Created January 25, 2016 11:19
Show Gist options
  • Save whitewhidow/167a873fb851990ea883 to your computer and use it in GitHub Desktop.
Save whitewhidow/167a873fb851990ea883 to your computer and use it in GitHub Desktop.
<?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