rfc:debugging_pdo_prepared_statement_emulation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
rfc:debugging_pdo_prepared_statement_emulation [2016/11/16 23:03] – fix formatting around discussion links adambaratz | rfc:debugging_pdo_prepared_statement_emulation [2016/11/17 16:27] – old revision restored (2016/11/15 23:48) adambaratz | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Debugging PDO Prepared Statement Emulation ====== | ====== PHP RFC: Debugging PDO Prepared Statement Emulation ====== | ||
- | * Version: 0.4 | + | * Version: 0.3 |
* Date: 2016-10-17 | * Date: 2016-10-17 | ||
* Author: Adam Baratz adambaratz@php.net | * Author: Adam Baratz adambaratz@php.net | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 14: | Line 14: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | People who use emulated prepared statements should be able to debug them within userland, without using additional tools. PDO already provides some debug functionality in the form of '' | + | People who use emulated prepared statements should be able to debug them within userland, without using additional tools. PDO already provides some debug functionality in the form of '' |
<code php> | <code php> | ||
- | /* Execute a prepared statement by binding PHP variables */ | + | $db = new PDO(...); |
- | $calories | + | |
- | $colour = ' | + | |
- | $sth = $dbh->prepare(' | + | // works with statements without bound values |
- | FROM fruit | + | $stmt = $db->query(' |
- | WHERE calories < ? AND colour = ?'); | + | var_dump($stmt->activeQueryString()); // => string(8) " |
- | $sth-> | + | |
- | $sth->bindValue(2, $colour, PDO:: | + | |
- | $sth->execute(); | + | |
- | $sth->debugDumpParams(); | + | $stmt = $db->prepare(' |
+ | $stmt-> | ||
- | /* | + | // returns unparsed query before execution |
+ | var_dump($stmt-> | ||
- | Output: | + | // returns parsed query after execution |
- | + | $stmt-> | |
- | SQL: [82] SELECT name, colour, calories | + | var_dump($stmt-> |
- | FROM fruit | + | |
- | WHERE calories < ? AND colour | + | |
- | Parsed SQL: [88] SELECT | + | |
- | FROM fruit | + | |
- | WHERE calories < 150 AND colour = 'red' | + | |
- | Params: | + | |
- | Key: Position #0: | + | |
- | paramno=0 | + | |
- | name=[0] | + | |
- | is_param=1 | + | |
- | param_type=1 | + | |
- | Key: Position #1: | + | |
- | paramno=1 | + | |
- | name=[0] "" | + | |
- | is_param=1 | + | |
- | param_type=2 | + | |
- | + | ||
- | */ | + | |
</ | </ | ||
- | The " | + | Since this would be a debug tool, the method shouldn' |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 64: | Line 43: | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
- | It's been suggested that PDO shouldn' | + | It's been suggested that PDO shouldn' |
+ | |||
+ | It's been suggested that this change | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
This project requires a 50%+1 majority. | This project requires a 50%+1 majority. | ||
- | <doodle title=" | + | <doodle title=" |
* Yes | * Yes | ||
* No | * No | ||
</ | </ | ||
+ | |||
+ | ===== Patches and Tests ===== | ||
+ | A working implementation with tests: https:// | ||
===== References ===== | ===== References ===== | ||
- | Initial discussion of this proposal on the internals mailing list: | + | Initial discussion of this proposal on the internals mailing list: http:// |
- | * http:// | + | |
- | * http:// | + | ===== Implementation ===== |
- | * http://marc.info/?l=php-internals& | + | This feature was implemented in PHP 7.2 ([[https://github.com/php/php-src/ |
rfc/debugging_pdo_prepared_statement_emulation.txt · Last modified: 2018/03/01 23:27 by carusogabriel