1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Core\Database\Logging;
13:
14: use Doctrine\DBAL\Logging\DebugStack;
15:
16: /**
17: * Extend Doctrine DebugStack to trigger XOOPS event
18: *
19: * @category Xoops\Core\Database\Logging
20: * @package Xoops\Core
21: * @author Richard Griffith <richard@geekwright.com>
22: * @copyright 2013 XOOPS Project (http://xoops.org)
23: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
24: * @version Release: 1.0
25: * @link http://xoops.org
26: * @see www.doctrine-project.org
27: */
28: class XoopsDebugStack extends DebugStack
29: {
30: /**
31: * stopQuery
32: *
33: * Perform usual Doctrine DebugStack stopQuery() and trigger event for loggers
34: *
35: * Event argument is array:
36: * - 'sql' => string SQL statement
37: * - 'params' => array of bound parameters
38: * - 'types' => array of parameter types
39: * - 'executionMS' => float of execution time in microseconds
40: *
41: * @return void
42: */
43: public function stopQuery()
44: {
45: parent::stopQuery();
46: \Xoops::getInstance()->events()->triggerEvent(
47: 'core.database.query.complete',
48: $this->queries[$this->currentQuery]
49: );
50: }
51: }
52: