Example #1
0
 /**
  * Binds a parameter to the specified variable name
  *
  * @param string $parameter Parameter identifier. For a prepared statement
  *   using named placeholders, this will be a parameter name of the form
  *   :name. For a prepared statement using question mark placeholders, this
  *   will be the 1-indexed position of the parameter.
  * @param mixed $variable Name of the PHP variable to bind to the SQL
  *   statement parameter.
  * @param int $dataType Explicit data type for the parameter using the
  *   PDO::PARAM_* constants.
  * @param int $maxLength Length of the data type. To indicate that a
  *   parameter is an OUT parameter from a stored procedure, you must
  *   explicitly set the length.
  * @param array $options [optional]
  * @return bool TRUE on success or FALSE on failure.
  * @todo Map PDO datatypes to oci8 datatypes and implement support for
  *   datatypes and length.
  */
 public function bindParam($parameter, &$variable, $dataType = \PDO::PARAM_STR, $maxLength = -1, $options = null)
 {
     //Replace the first @oci8param to a pseudo named parameter
     if (is_numeric($parameter)) {
         $parameter = ':autoparam' . $parameter;
     }
     //Adapt the type
     switch ($dataType) {
         case \PDO::PARAM_BOOL:
             $oci_type = SQLT_INT;
             break;
         case \PDO::PARAM_NULL:
             $oci_type = SQLT_CHR;
             break;
         case \PDO::PARAM_INT:
             $oci_type = SQLT_INT;
             break;
         case \PDO::PARAM_STR:
             $oci_type = SQLT_CHR;
             break;
         case \PDO::PARAM_LOB:
             $oci_type = OCI_B_BLOB;
             // create a new descriptor for blob
             $variable = $this->_pdoOci8->getNewDescriptor();
             break;
         case \PDO::PARAM_STMT:
             $oci_type = OCI_B_CURSOR;
             //Result sets require a cursor
             $variable = $this->_pdoOci8->getNewCursor();
             break;
         default:
             $oci_type = SQLT_CHR;
             break;
     }
     //Bind the parameter
     $result = oci_bind_by_name($this->_sth, $parameter, $variable, $maxLength, $oci_type);
     return $result;
 }