Created
November 8, 2017 10:39
-
-
Save jreinke/2af96be267854a1bb1aa3df8ae95fdc8 to your computer and use it in GitHub Desktop.
Display Magento 2 SQL queries
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 | |
/* | |
Edit file vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php | |
and add the following code at line 237 | |
*/ | |
$sqlQuery = $sql; | |
if (is_string(key($bind))) { | |
foreach ($bind as $field => $value) { | |
$sqlQuery = str_replace($field, $this->quote($value), $sqlQuery); | |
} | |
} else if (is_numeric(key($bind))) { | |
$offset = 0; | |
foreach ($bind as $value) { | |
$pos = strpos($sqlQuery, '?', $offset); | |
if (null === $value) { | |
$value = 'NULL'; | |
} else if (is_string($value)) { | |
$value = $this->quote($value); | |
} | |
$sqlQuery = substr_replace($sqlQuery, $value, $pos, 1); | |
$offset = $pos + strlen($value); | |
} | |
} | |
echo '<pre>';print_r($sqlQuery);echo '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment