ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:prepare

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
reference:prepare [2015/12/04 17:22] – [Usage] mnewnhamv5:reference:connection:prepare [2016/11/02 12:44] – [prepare] add link to comparison matrix dregad
Line 2: Line 2:
 ~~NOTOC~~ ~~NOTOC~~
 <WRAP info> <WRAP info>
-Support for this function is limited. See the feature compatibility matrix+Support for this function is limited. See the [[v5:database:feature_comparison]].
 </WRAP> </WRAP>
-<WRAP right box>+<WRAP right box 250px> 
 +== See Also == 
 +[[v5:reference:connection:preparesp]]\\ 
 +[[v5:reference:connection:execute]] for an explanation of the bind variables
 == Syntax == == Syntax ==
   mixed prepare (   mixed prepare (
Line 13: Line 16:
  
 ===== Description ===== ===== Description =====
-The function ''prepare()'' prepares an SQL statement. If the statement is valid the function return a resource otherwise it returns false.+The method ''prepare()'' prepares an SQL statement.  
 +  * If the database supports prepared statements and the statement is valid the method return a resource  
 +  * If the database supports prepared statements and the statement is invalid the method returns false
 +  * If the database does not support prepared statements, the method returns a string containing the SQL statement (see below).
  
 ------------------------------------- -------------------------------------
Line 24: Line 30:
 $handle = $db->prepare('SELECT * FROM customers WHERE customer_no=?'); $handle = $db->prepare('SELECT * FROM customers WHERE customer_no=?');
  
-$params = array(0=>100);+$bindVariables = array(0=>100);
  
 /* /*
 * Send an array to execute * Send an array to execute
 */ */
-$result = $db->execute(array($handle,$params));+$result = $db->execute(array($handle,$bindVariables));
 </code> </code>
  
 For compatibility purposes, if the database does not support prepared statements, the SQL statement is returned into the ''$handle'' variable. When sent to the ''execute()'' function,  The statement will be parsed to include the variables, and the statement will execute the same as if passed without parameters, and as if the DBMS supported prepared statements. For compatibility purposes, if the database does not support prepared statements, the SQL statement is returned into the ''$handle'' variable. When sent to the ''execute()'' function,  The statement will be parsed to include the variables, and the statement will execute the same as if passed without parameters, and as if the DBMS supported prepared statements.
- 
  
v5/reference/connection/prepare.txt · Last modified: 2019/08/09 15:42 by dregad