PHP code example of phpcodemaker / cake-debug-query
1. Go to this page and download the library: Download phpcodemaker/cake-debug-query library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpcodemaker / cake-debug-query example snippets
<!-- language: php -->
public function debugQuery($formatSQL = true): string
{
$query = $this->sql();
$placeholderArray = $this->getValueBinder()->bindings();
if (null != $placeholderArray) {
foreach ($placeholderArray as $placeholder => $paramArray) {
switch ($paramArray['type']) {
case 'json' :
$QueryParam[substr($placeholder, 1)] = '\'' . json_encode($paramArray['value'], JSON_NUMERIC_CHECK) . '\'';
break; case 'boolean':
case 'integer':
$QueryParam[substr($placeholder, 1)] = $paramArray['value'];
break;
case 'string':
case 'text' :
default :
$QueryParam[substr($placeholder, 1)] = "'{$paramArray['value']}'";
break;
}
}
}
$outputQuery = $query;
if (!empty($QueryParam)) {
$outputQuery = \Cake\Utility\Text::insert($query, $QueryParam);
}
return $formatSQL ? \SqlFormatter::format($outputQuery) : $outputQuery;
}