Manuál PHP | ||
---|---|---|
PÅ™edcházejÃcà | Dalšà |
db2_bind_param
Popis
bool db2_bind_param ( resource stmt, int parameter-number, string variable-name [, int parameter-type [, int data-type [, int precision [, int scale]]]] )Binds a PHP variable to an SQL statement parameter in a statement resource returned by db2_prepare(). This function gives you more control over the parameter type, data type, precision, and scale for the parameter than simply passing the variable as part of the optional input array to db2_execute().
Seznam parametrů
stmt
A prepared statement returned from db2_prepare().
parameter-number
Specifies the 1-indexed position of the parameter in the prepared statement.
variable-name
A string specifying the name of the PHP variable to bind to the parameter specified by
parameter-number
.parameter-type
A constant specifying whether the PHP variable should be bound to the SQL parameter as an input parameter (DB2_PARAM_IN), an output parameter (DB2_PARAM_OUT), or as a parameter that accepts input and returns output (DB2_PARAM_INOUT). To avoid memory overhead, you can also specify DB2_PARAM_FILE to bind the PHP variable to the name of a file that contains large object (BLOB, CLOB, or DBCLOB) data.
data-type
A constant specifying the SQL data type that the PHP variable should be bound as: one of DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG .
precision
Specifies the precision with which the variable should be bound to the database.
scale
Specifies the scale with which the variable should be bound to the database.
PÅ™Ãklady
PÅ™Ãklad 1. Binding PHP variables to a prepared statement The SQL statement in the following example uses two input parameters in the WHERE clause. We call db2_bind_param() to bind two PHP variables to the corresponding SQL parameters. Notice that the PHP variables do not have to be declared or assigned before the call to db2_bind_param(); in the example, $lower_limit is assigned a value before the call to db2_bind_param(), but $upper_limit is assigned a value after the call to db2_bind_param(). The variables must be bound and, for parameters that accept input, must have any value assigned, before calling db2_execute().
Výše uvedený pÅ™Ãklad vypÃÅ¡e:
|
PÅ™Ãklad 3. Inserting a binary large object (BLOB) directly from a file The data for large objects are typically stored in files, such as XML documents or audio files. Rather than reading an entire file into a PHP variable, and then binding that PHP variable into an SQL statement, you can avoid some memory overhead by binding the file directly to the input parameter of your SQL statement. The following example demonstrates how to bind a file directly into a BLOB column.
|
PÅ™edcházejÃcà | Domů | Dalšà |
db2_autocommit | Nahoru | <