当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Db_Adapter_Abstract::supportsParameters方法代码示例

本文整理汇总了PHP中Zend_Db_Adapter_Abstract::supportsParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Abstract::supportsParameters方法的具体用法?PHP Zend_Db_Adapter_Abstract::supportsParameters怎么用?PHP Zend_Db_Adapter_Abstract::supportsParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Db_Adapter_Abstract的用法示例。


在下文中一共展示了Zend_Db_Adapter_Abstract::supportsParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bindParam

 /**
  * 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 Zend_Db_Statement_Exception
          */
         require_once 'Zend/Db/Statement/Exception.php';
         throw new Zend_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 Zend_Db_Statement_Exception
          */
         require_once 'Zend/Db/Statement/Exception.php';
         throw new Zend_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);
 }
开发者ID:Yaoming9,项目名称:Projet-Web-PhP,代码行数:45,代码来源:Statement.php

示例2: _normalizeBindParam

 /**
  * Check sanity of bind parameters.  Throw exceptions if params are
  * not valid.  
  *
  * @param mixed $parameter Name the parameter, either integer or string.
  * @param mixed $variable Reference to PHP variable containing the value.
  * @return integer
  * @throws Zend_Db_Statement_Exception
  */
 protected function _normalizeBindParam($parameter, &$variable)
 {
     $position = null;
     if ((int) $parameter > 0) {
         if ($this->_adapter->supportsParameters('positional') === false) {
             /**
              * @see Zend_Db_Statement_Exception
              */
             require_once 'Zend/Db/Statement/Exception.php';
             throw new Zend_Db_Statement_Exception("Invalid bind-variable position '{$parameter}'");
         }
         if ($parameter > 0 && $parameter <= count($this->_sqlParam)) {
             // bind by position, 1-based
             $position = $parameter - 1;
             $this->_bindParam[$position] =& $variable;
         } else {
             /**
              * @see Zend_Db_Statement_Exception
              */
             require_once 'Zend/Db/Statement/Exception.php';
             throw new Zend_Db_Statement_Exception("Invalid bind-variable position '{$parameter}'");
         }
     } else {
         if (is_string($parameter)) {
             if ($this->_adapter->supportsParameters('named') === false) {
                 /**
                  * @see Zend_Db_Statement_Exception
                  */
                 require_once 'Zend/Db/Statement/Exception.php';
                 throw new Zend_Db_Statement_Exception("Invalid bind-variable position '{$parameter}'");
             }
             // bind by name. make sure it has a colon on it.
             if ($parameter[0] != ':') {
                 $parameter = ":{$parameter}";
             }
             // look up its position in the params.
             $position = array_search($parameter, $this->_sqlParam);
             if (is_integer($position)) {
                 $this->_bindParam[$position] =& $variable;
             } else {
                 /**
                  * @see Zend_Db_Statement_Exception
                  */
                 require_once 'Zend/Db/Statement/Exception.php';
                 throw new Zend_Db_Statement_Exception("Invalid bind-variable position '{$parameter}'");
             }
         } else {
             /**
              * @see Zend_Db_Statement_Exception
              */
             require_once 'Zend/Db/Statement/Exception.php';
             throw new Zend_Db_Statement_Exception('Invalid bind-variable position');
         }
     }
     return $position;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:65,代码来源:Statement.php

示例3: insertOrUpdate

 public function insertOrUpdate($obj)
 {
     if ($obj instanceof My_Model_Domain) {
         if ($obj->getClientIdUnsetFromData()) {
             $obj->unsetField($obj->getClientIdKey());
         }
         $data = $obj->getData();
     } elseif (is_array($obj)) {
         $data = $obj;
     } else {
         throw new Exception("Unsupported datatype used in insert", -1001);
     }
     // extract and quote col names from the array keys
     $cols = array();
     $vals = array();
     $i = 0;
     foreach ($data as $col => $val) {
         $cols[] = $this->_connection->quoteIdentifier($col, true);
         if ($val instanceof Zend_Db_Expr) {
             $vals[] = $val->__toString();
             unset($data[$col]);
         } else {
             if ($this->_connection->supportsParameters('positional')) {
                 $vals[] = '?';
             } else {
                 if ($this->_connection->supportsParameters('named')) {
                     unset($data[$col]);
                     $data[':col' . $i] = $val;
                     $vals[] = ':col' . $i;
                     $i++;
                 } else {
                     /** @see Zend_Db_Adapter_Exception */
                     require_once 'Zend/Db/Adapter/Exception.php';
                     throw new Zend_Db_Adapter_Exception(get_class($this->_connection) . " doesn't support positional or named binding");
                 }
             }
         }
     }
     // build the statement
     $sql = "INSERT INTO " . $this->_connection->quoteIdentifier($this->_tablename, true) . ' (' . implode(', ', $cols) . ') ' . 'VALUES (' . implode(', ', $vals) . ')';
     $duplicate = " ON DUPLICATE KEY UPDATE ";
     foreach ($cols as $index => $col) {
         $duplicate .= $col . " = " . $vals[$index] . ",";
     }
     $duplicate = rtrim($duplicate, ",");
     $sql .= $duplicate;
     // execute the statement and return the number of affected rows
     if ($this->_connection->supportsParameters('positional')) {
         $data = array_values($data);
     }
     //because we have two
     $data = array_merge($data, $data);
     $stmt = $this->_connection->query($sql, $data);
     $result = $stmt->rowCount();
     return $result;
 }
开发者ID:milosilic,项目名称:wbcore_mapper,代码行数:56,代码来源:Mysql.php

示例4: supportsParameters

 /**
  * Check if the adapter supports real SQL parameters.
  *
  * @param string $type 'positional' or 'named'
  * @return bool
  */
 public function supportsParameters($type)
 {
     return $this->_adapter->supportsParameters($type);
 }
开发者ID:cwcw,项目名称:cms,代码行数:10,代码来源:Abstract.php


注:本文中的Zend_Db_Adapter_Abstract::supportsParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。