Exemple #1
0
 /**
  * Binds a parameter to the specified variable name.
  *
  * @param mixed $parameter Name the parameter, either integer or string.
  * @param mixed $variable  Reference to PHP variable containing the value.
  * @param mixed $type      OPTIONAL Datatype of SQL parameter.
  * @param mixed $length    OPTIONAL Length of SQL parameter.
  * @param mixed $options   OPTIONAL Other options.
  * @return bool
  */
 public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
 {
     if (!is_int($parameter) && !is_string($parameter)) {
         /**
          * @see JO_Db_Statement_Exception
          */
         require_once 'JO/Db/Statement/Exception.php';
         throw new JO_Db_Statement_Exception('Invalid bind-variable position');
     }
     $position = null;
     if (($intval = (int) $parameter) > 0 && $this->_adapter->supportsParameters('positional')) {
         if ($intval >= 1 || $intval <= count($this->_sqlParam)) {
             $position = $intval;
         }
     } else {
         if ($this->_adapter->supportsParameters('named')) {
             if ($parameter[0] != ':') {
                 $parameter = ':' . $parameter;
             }
             if (in_array($parameter, $this->_sqlParam) !== false) {
                 $position = $parameter;
             }
         }
     }
     if ($position === null) {
         /**
          * @see JO_Db_Statement_Exception
          */
         require_once 'JO/Db/Statement/Exception.php';
         throw new JO_Db_Statement_Exception("Invalid bind-variable position '{$parameter}'");
     }
     // Finally we are assured that $position is valid
     $this->_bindParam[$position] =& $variable;
     return $this->_bindParam($position, $variable, $type, $length, $options);
 }