rfc:debugging_pdo_prepared_statement_emulation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:debugging_pdo_prepared_statement_emulation [2016/10/26 19:04] – reduce to single proposal adambaratz | rfc:debugging_pdo_prepared_statement_emulation [2016/11/16 23:03] – fix formatting around discussion links adambaratz | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Debugging PDO Prepared Statement Emulation ====== | ====== PHP RFC: Debugging PDO Prepared Statement Emulation ====== | ||
- | * Version: 0.3 | + | * Version: 0.4 |
* 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> | ||
- | $db = new PDO(...); | + | /* Execute a prepared statement by binding PHP variables */ |
+ | $calories | ||
+ | $colour = ' | ||
- | // works with statements without bound values | + | $sth = $dbh->prepare(' |
- | $stmt = $db->query(' | + | FROM fruit |
- | var_dump($stmt->activeQueryString()); // => string(8) " | + | WHERE calories < ? AND colour = ?'); |
+ | $sth-> | ||
+ | $sth->bindValue(2, $colour, PDO:: | ||
+ | $sth->execute(); | ||
- | $stmt = $db->prepare(' | + | $sth->debugDumpParams(); |
- | $stmt-> | + | |
- | // returns unparsed query before execution | + | /* |
- | var_dump($stmt-> | + | |
- | // returns parsed query after execution | + | Output: |
- | $stmt-> | + | |
- | var_dump($stmt-> | + | SQL: [82] SELECT name, colour, calories |
+ | 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 | ||
+ | |||
+ | */ | ||
</ | </ | ||
- | Since this would be a debug tool, the method shouldn' | + | The " |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 43: | Line 64: | ||
===== 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. | ||
- | ===== Patches and Tests ===== | + | <doodle title=" |
- | A working implementation with tests: https:// | + | * Yes |
+ | * No | ||
+ | </doodle> | ||
===== References ===== | ===== References ===== | ||
- | Initial discussion of this proposal on the internals mailing list: http:// | + | Initial discussion of this proposal on the internals mailing list: |
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// |
rfc/debugging_pdo_prepared_statement_emulation.txt · Last modified: 2018/03/01 23:27 by carusogabriel