v5:userguide:learn_bind:bind_vars
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v5:userguide:learn_bind:bind_vars [2016/03/23 01:21] – [Description] mnewnham | v5:userguide:learn_bind:bind_vars [2016/03/23 02:04] (current) – mnewnham | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <- ^ v5: | ||
+ | ~~NOTOC~~ | ||
====== Using Bind Variables ====== | ====== Using Bind Variables ====== | ||
===== Description ===== | ===== Description ===== | ||
Line 14: | Line 16: | ||
* Statement without Binding | * Statement without Binding | ||
*/ | */ | ||
- | $sql = " | + | $sql = " |
$result = $db-> | $result = $db-> | ||
Line 21: | Line 23: | ||
*/ | */ | ||
$bindVars = array(' | $bindVars = array(' | ||
- | $sql = " | + | $sql = " |
$result = $db-> | $result = $db-> | ||
</ | </ | ||
Line 27: | Line 29: | ||
Note that the number of variable in the '' | Note that the number of variable in the '' | ||
- | ===== Bind Placeholders Across Databases ===== | ||
- | Bind placeholders vary from one database to another, so ADOdb provides a method [[v5: | ||
- | <code php> | + | If an ADOdb method does support binding, the syntax definition in the documentation will appear similar to this: |
- | $bindVars = array(' | + | |
- | + | ||
- | $col1Ph = $db-> | + | |
- | $col2Ph = $db-> | + | |
- | $col2Ph = $db-> | + | |
- | + | ||
- | $sql = " | + | |
- | $result = $db-> | + | |
- | </ | + | |
- | In the above example, you can see that it is necessary to obtain a unique placeholder for each bind variable. This is because in some databases, the placeholder is uniquely associated with the database. So in the above example would appear as follows: | + | <WRAP box 350px> |
- | ==== MySQL ==== | + | == Syntax |
- | | + | |
- | ==== Oracle ==== | + | |
- | | + | string $sqlStatement, |
- | ==== PostgreSQL ==== | + | optional mixed $bindVars |
- | | + | |
- | + | </ | |
- | ===== Databases Without Bind Support ===== | + | |
- | You can still use the bind form of execute in ADOdb if the database does not support binding. In this case ADOdb simply rewrites the query statement for you back into the non-bind form. | + | |
v5/userguide/learn_bind/bind_vars.1458692508.txt.gz · Last modified: (external edit)