Skip to content

Instantly share code, notes, and snippets.

@lorenzo
Created May 14, 2018 19:44
Show Gist options
  • Save lorenzo/39b3297cfba428243c5b875d48d0d151 to your computer and use it in GitHub Desktop.
Save lorenzo/39b3297cfba428243c5b875d48d0d151 to your computer and use it in GitHub Desktop.
<?php
namespace App\ORM;
use Cake\Error\Debugger;
use Cake\ORM\Query;
class DebuggingQuery extends Query
{
public function __construct($connection, $table)
{
parent::__construct($connection, $table);
$this->addComment();
}
public function addComment()
{
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$comment = $trace[4]['class'] . '::' . $trace[4]['function'] . '@' . $trace[3]['line']; // change the numbers at will until you get the right spot
$this->modifier(['/* ' . $comment . ' */']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment