| ADOdb Library for PHP Manual | ||
|---|---|---|
| Prev | InParameter, OutParameter, Param and Parameter | Next |
InParameter() is a wrapper function that calls Parameter() with $isOutput=false. The advantage of this function is that it is self-documenting, because the $isOutput parameter is no longer needed. Only for mssql and oci8 currently.
Here is an example using oci8:
# For oracle, Prepare and PrepareSP are identical $stmt = $db->PrepareSP( "declare RETVAL integer; begin :RETVAL := SP_RUNSOMETHING(:myid,:group); end;"); $db->InParameter($stmt,$id,'myid'); $db->InParameter($stmt,$group,'group',64); $db->OutParameter($stmt,$ret,'RETVAL');
$db->Execute($stmt);
The same example using mssql:
# @RETVAL = SP_RUNSOMETHING @myid,@group
$stmt = $db->PrepareSP('SP_RUNSOMETHING');
# note that the parameter name does not have @ in front!
$db->InParameter($stmt,$id,'myid');
$db->InParameter($stmt,$group,'group',64);
# return value in mssql - RETVAL is hard-coded name
$db->OutParameter($stmt,$ret,'RETVAL');
$db->Execute($stmt);
Note that the only difference between the oci8 and mssql implementations is $sql.
If $type parameter is set to false, in mssql, $type will be dynamicly determined based on the type of the PHP variable passed (string => SQLCHAR, boolean =>SQLINT1, integer =>SQLINT4 or float/double=>SQLFLT8).
In oci8, $type can be set to OCI_B_FILE (Binary-File), OCI_B_CFILE (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) and OCI_B_ROWID (ROWID). To pass in a null, use $db->Parameter($stmt, $null=null, 'param').
OutParameter() is a wrapper function that calls Parameter() with $isOutput=true. The advantage of this function is that it is self-documenting, because the $isOutput parameter is no longer needed. Only for mssql and oci8 currently.
For an example, see InParameter.
This function is deprecated. Use InParameter( ) and OutParameter( ) instead.
Adds a bind parameter suitable for return values or special data handling (eg. LOBs) after a statement has been prepared using PrepareSP(). Only for mssql and oci8 currently. The parameters are:
$stmt Statement returned by Prepare() or PrepareSP().
$var PHP variable to bind to. Make sure you pre-initialize
it!
$name Name of stored procedure variable name to bind to.
[$isOutput] Indicates direction of parameter 0/false=IN 1=OUT
2= IN/OUT. This is ignored in oci8 as this driver auto-detects the direction.
[$maxLen] Maximum length of the parameter variable.
[$type] Consult mssql_bind
and ocibindbyname
docs at php.net for more info on legal values for type.
Generates a bind placeholder portably. For most databases, the bind placeholder is "?". However some databases use named bind parameters such as Oracle, eg ":somevar". This allows us to portably define an SQL statement with bind parameters:
$sql = 'insert into table (col1,col2) values ('.$DB->Param('a').','.$DB->Param('b').')';
# generates 'insert into table (col1,col2) values (?,?)'
# or 'insert into table (col1,col2) values (:a,:b)'
$stmt = $DB->Prepare($sql);
$stmt = $DB->Execute($stmt,array('one','two'));
| Prev | Home | Next |
| PrepareSP | Up | GetOne |