noahheck / e_pdostatement Goto Github PK
View Code? Open in Web Editor NEWDrop in replacement for default PHP PDOStatement class allowing devs to view an interpolated version of a parameterized query
License: Other
Drop in replacement for default PHP PDOStatement class allowing devs to view an interpolated version of a parameterized query
License: Other
Hi,
I've an issue with the last release. When I try to execute it, my page crash (aborted on firebug).
It seems to be on the regex : $testParam = "/({$marker}(?!\w))(?=(?:[^\"']|["'][^\"']["'])$)/";
When i replaced it by the old one ($testParam = "/" . $marker . "(?!\w)/";), it's ok
Apache/2.4.18 (Win32) PHP/5.6.19
Hi,
I'm facing the following issue when using EPDOStatement:
During inheritance of PDOStatement: Uncaught Whoops\Exception\ErrorException: Return type of EPDOStatement\EPDOStatement::bindParam($param, &$value, $datatype = PDO::PARAM_STR, $length = 0, $driverOptions = false) should either be compatible with PDOStatement::bindParam(string|int $param, mixed &$var, int $type = PDO::PARAM_STR, int $maxLength = 0, mixed $driverOptions = null): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/myuser/Documents/Projects/myapp/vendor/noahheck/e_pdostatement/src/EPDOStatement.php:80
Stack trace:
#0 /Users/myuser/Documents/Projects/myapp/vendor/noahheck/e_pdostatement/src/EPDOStatement.php(25): Whoops\Run->handleError(8192, 'Return type of ...', '/Users/myuser/...', 80)
#1 /Users/myuser/Documents/Projects/myapp/vendor/composer/ClassLoader.php(571): include('/Users/myuser/...')
#2 /Users/myuser/Documents/Projects/myapp/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/Users/myuser/...')
#3 [internal function]: Composer\Autoload\ClassLoader->loadClass('EPDOStatement\\E...')
#4 /Users/myuser/Documents/Projects/myapp/src/php/Database/DBConnection.php(21): PDO->setAttribute(13, Array)
[...]
I'm using Whoops for catching exceptions while in "debug" mode on my site.
I'm using PHP 8.1.11 and the version 2.3.1 of the package via composer.
Here is the content of the DBConnection
class:
namespace App\Database;
use App\Utils\Config;
use PDO;
class DBConnection {
/**
* @var PDO
*/
private static $pdo;
public static function getPDO(): PDO {
if (!isset(self::$pdo)) {
$dsn = "mysql:host=" . $_ENV['DB_HOST'] . ";dbname=" . $_ENV['DB_NAME'];
$user = $_ENV['DB_USER'];
$passwd = $_ENV['DB_PASSWORD'];
self::$pdo = new PDO($dsn, $user, $passwd);
if (Config::isDebugEnabled()) {
self::$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array("EPDOStatement\EPDOStatement", [self::$pdo]));
}
}
return self::$pdo;
}
}
What could be the issue?
Thank you in advance for your support.
I notice there is $this->debug(
in the functions. Can you please update the readme/wiki on how to use this functionality.
Hi,
If I run this query : "INSERT INTO myTable (id,Mycolumn) VALUES (:myId, :myColumn) ON DUPLICATE UPDATE Mycolumn = :myColumn)"
and params are : array(myColumn => "Toto", myId => 125)
If I want to see the query by using interpolateQuery , I've only the first parameter which is replaced :
"
INSERT INTO myTable (id,Mycolumn) VALUES (125, "Toto) ON DUPLICATE UPDATE Mycolumn ="")
"
But the query is well executed...
Is there a way to show the full query if a parameter is used more than one time ?
Hello,
have you an idea how to implement this Statement Addon for the MySQLi in PHP? I use MySQLi and need this functionality to echo the full sql querystring.
Please help. Thanks
Dave
i.e. password_hash function may produce something like this:
$2y$10$Xs/oqD0cVCb7hM1suoAD/Oqf4tlm5suTb8IsczDTnttiWUtHsb5ay
but the full query value ends up like this:
y$Xs/oqD0cVCb7hM1suoAD/Oqf4tlm5suTb8IsczDTnttiWUtHsb5ay
$2y$10$Xs/oqD0cVCb7hM1suoAD/Oqf4tlm5suTb8IsczDTnttiWUtHsb5ay
y $Xs/oqD0cVCb7hM1suoAD/Oqf4tlm5suTb8IsczDTnttiWUtHsb5ay
More problematic would be the presence of a $0
backreference in the replacement value (potentially re-adding the placeholder to the content string)
Query (with param test_id = 3):
SELECT * FROM test_items WHERE test_id = :test_id
Result in fullQuery:
SELECT * FROM test_items WHERE '3' = :test_id
fix for that (just colon added):
$testParam = "/:" . $key . "(?!\w)/";
Result after fix:
SELECT * FROM test_items WHERE test_id= '3'
Seems to work fine for me.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.