Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

DebugPDO executedQueryString - quoting #775

Merged
merged 1 commit into from Oct 18, 2013

Conversation

Projects
None yet
4 participants
Contributor

thedave80 commented Oct 15, 2013

When displaying executed query from DebugPDO (i.e. in FirePHP), sometimes the outputted query is not valid.
This can be fixed with a simple quoting in DebugPDOStatement class.

Before: http://d.pr/i/Mgyi
After: http://d.pr/i/Xx6X

Some examples:

// works without change
$con = Propel::getConnection();
$con->query("SELECT * FROM temp WHERE name LIKE '%david%'");

// also works
$prepStmt = $con->prepare("SELECT * FROM temp WHERE name LIKE :name");
$prepStmt->bindValue('name', '%david%');
$prepStmt->execute();

// does not work, since params get quoted different
$con = Propel::getConnection();
$prepStmt = $con->prepare("SELECT * FROM temp WHERE name LIKE :p1");
$prepStmt->execute(array(':p1' => '%john%'));

Member

staabm commented Oct 15, 2013

looks good to me. please add a unit test.

Contributor

thedave80 commented Oct 16, 2013

Added some tests, had to rework some handling how bindValue/bindParam works in DebugPDOStatement. Could be used to actually display bindParams or values in executed query string, instead of :p1 :p2 ...

@jaugustin jaugustin commented on an outdated diff Oct 16, 2013

runtime/lib/Propel.php
@@ -545,7 +545,7 @@ public static function setConnection($name, PropelPDO $con, $mode = Propel::CONN
* @param string $name The datasource name that is used to look up the DSN from the runtime configuration file.
* @param string $mode The connection mode (this applies to replication systems).
*
- * @return PDO A database connection
+ * @return PropelPDO PDO A database connection
@jaugustin

jaugustin Oct 16, 2013

Member

I think it should be PropelPDO or PDO but not both ;)

Contributor

thedave80 commented Oct 16, 2013

whoops, thats right 👍
I squashed all commits, can any one take a look at it?

@willdurand willdurand added a commit that referenced this pull request Oct 18, 2013

@willdurand willdurand Merge pull request #775 from thedave80/DebugPDO-fix
DebugPDO executedQueryString - quoting
ae7bb75

@willdurand willdurand merged commit ae7bb75 into propelorm:master Oct 18, 2013

1 check passed

default The Travis CI build passed
Details
Member

staabm commented Oct 18, 2013

@thedave80 good job. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment