pdo:insert_statements
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
pdo:insert_statements [2016/10/14 09:27] – created peter | pdo:insert_statements [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 8: | Line 8: | ||
</ | </ | ||
- | + | ===== Preparing Statements using SQL functions | |
- | You may ask how do you use SQL functions | + | |
<code php> | <code php> | ||
Line 58: | Line 57: | ||
</ | </ | ||
+ | |||
+ | Note we used **bindValue** and not **bindParam**. | ||
+ | |||
+ | |||
+ | ===== Executing prepared statements in a loop ===== | ||
+ | |||
+ | Prepared statements excel in being called multiple times in a row with different values. | ||
+ | |||
+ | Typically this is done by binding parameters with **bindParam**. | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | $values = array(' | ||
+ | $name = ''; | ||
+ | $stmt = $db-> | ||
+ | $stmt-> | ||
+ | foreach($values as $name) { | ||
+ | $stmt-> | ||
+ | } | ||
+ | </ |
pdo/insert_statements.1476437251.txt.gz · Last modified: 2020/07/15 09:30 (external edit)