當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Adapter\ParameterContainer類代碼示例

本文整理匯總了PHP中Zend\Db\Adapter\ParameterContainer的典型用法代碼示例。如果您正苦於以下問題:PHP ParameterContainer類的具體用法?PHP ParameterContainer怎麽用?PHP ParameterContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ParameterContainer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processOffset

 protected function processOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
 {
     if ($this->offset === null) {
         return null;
     }
     if ($driver) {
         $parameterContainer->offsetSet('offset', (int) $this->offset, ParameterContainer::TYPE_INTEGER);
         return array($driver->formatParameterName('offset'));
     }
     return array($this->offset);
 }
開發者ID:leonardovn86,項目名稱:zf2_basic2013,代碼行數:11,代碼來源:SelectDecorator.php

示例2: processOffset

 protected function processOffset(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null)
 {
     if ($this->offset === null) {
         return null;
     }
     if ($adapter) {
         $parameterContainer->offsetSet('offset', $this->offset, ParameterContainer::TYPE_INTEGER);
         return array($adapter->getDriver()->formatParameterName('offset'));
     } else {
         return array($this->offset);
     }
 }
開發者ID:Baft,項目名稱:Zend-Form,代碼行數:12,代碼來源:SelectDecorator.php

示例3: processLimitOffset

 /**
  * @param PlatformInterface $platform
  * @param DriverInterface $driver
  * @param ParameterContainer $parameterContainer
  * @param $sqls
  * @param $parameters
  * @return null
  */
 protected function processLimitOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters)
 {
     if ($this->limit === null && $this->offset === null) {
         return;
     }
     $selectParameters = $parameters[self::SELECT];
     /** if this is a DISTINCT query then real SELECT part goes to second element in array **/
     $parameterIndex = 0;
     if ($selectParameters[0] === 'DISTINCT') {
         unset($selectParameters[0]);
         $selectParameters = array_values($selectParameters);
         $parameterIndex = 1;
     }
     $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR;
     foreach ($selectParameters[0] as $i => $columnParameters) {
         if ($columnParameters[0] == self::SQL_STAR || isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR || strpos($columnParameters[0], $starSuffix)) {
             $selectParameters[0] = [[self::SQL_STAR]];
             break;
         }
         if (isset($columnParameters[1])) {
             array_shift($columnParameters);
             $selectParameters[0][$i] = $columnParameters;
         }
     }
     // first, produce column list without compound names (using the AS portion only)
     array_unshift($sqls, $this->createSqlFromSpecificationAndParameters(['SELECT %1$s FROM (' => current($this->specifications[self::SELECT])], $selectParameters));
     if ($parameterContainer) {
         // create bottom part of query, with offset and limit using row_number
         $limitParamName = $driver->formatParameterName('limit');
         $offsetParamName = $driver->formatParameterName('offset');
         $offsetForSumParamName = $driver->formatParameterName('offsetForSum');
         array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' . $offsetParamName . '+1 AND ' . $limitParamName . '+' . $offsetForSumParamName);
         $parameterContainer->offsetSet('offset', $this->offset);
         $parameterContainer->offsetSet('limit', $this->limit);
         $parameterContainer->offsetSetReference('offsetForSum', 'offset');
     } else {
         array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' . (int) $this->offset . '+1 AND ' . (int) $this->limit . '+' . (int) $this->offset);
     }
     if (isset($sqls[self::ORDER])) {
         $orderBy = $sqls[self::ORDER];
         unset($sqls[self::ORDER]);
     } else {
         $orderBy = 'ORDER BY (SELECT 1)';
     }
     // add a column for row_number() using the order specification
     $parameters[self::SELECT][$parameterIndex][] = ['ROW_NUMBER() OVER (' . $orderBy . ')', '[__ZEND_ROW_NUMBER]'];
     $sqls[self::SELECT] = $this->createSqlFromSpecificationAndParameters($this->specifications[self::SELECT], $parameters[self::SELECT]);
 }
開發者ID:zendframework,項目名稱:zend-db,代碼行數:56,代碼來源:SelectDecorator.php

示例4: execute

 /**
  * Execute
  *
  * @param null $parameters
  * @return Result
  */
 public function execute($parameters = null)
 {
     if (!$this->isPrepared) {
         $this->prepare();
     }
     /** START Standard ParameterContainer Merging Block */
     if (!$this->parameterContainer instanceof ParameterContainer) {
         if ($parameters instanceof ParameterContainer) {
             $this->parameterContainer = $parameters;
             $parameters = null;
         } else {
             $this->parameterContainer = new ParameterContainer();
         }
     }
     if (is_array($parameters)) {
         $this->parameterContainer->setFromArray($parameters);
     }
     /** END Standard ParameterContainer Merging Block */
     if ($this->profiler) {
         $this->profiler->profilerStart($this);
     }
     set_error_handler(function () {
     }, E_WARNING);
     // suppress warnings
     $response = db2_execute($this->resource, $this->parameterContainer->getPositionalArray());
     restore_error_handler();
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($response === false) {
         throw new Exception\RuntimeException(db2_stmt_errormsg($this->resource));
     }
     $result = $this->driver->createResult($this->resource);
     return $result;
 }
開發者ID:leonardovn86,項目名稱:zf2_basic2013,代碼行數:41,代碼來源:Statement.php

示例5: bindParametersFromContainer

 /**
  * Bind parameters from container
  *
  * @param ParameterContainer $pContainer
  */
 protected function bindParametersFromContainer()
 {
     $parameters = $this->parameterContainer->getNamedArray();
     foreach ($parameters as $name => &$value) {
         if ($this->parameterContainer->offsetHasErrata($name)) {
             switch ($this->parameterContainer->offsetGetErrata($name)) {
                 case ParameterContainer::TYPE_NULL:
                     $type = null;
                     $value = null;
                     break;
                 case ParameterContainer::TYPE_DOUBLE:
                 case ParameterContainer::TYPE_INTEGER:
                     $type = SQLT_INT;
                     if (is_string($value)) {
                         $value = (int) $value;
                     }
                     break;
                 case ParameterContainer::TYPE_BINARY:
                     $type = SQLT_BIN;
                     break;
                 case ParameterContainer::TYPE_STRING:
                 default:
                     $type = SQLT_CHR;
                     break;
             }
         } else {
             $type = SQLT_CHR;
         }
         oci_bind_by_name($this->resource, $name, $value, -1, $type);
     }
 }
開發者ID:razvansividra,項目名稱:pnlzf2-1,代碼行數:36,代碼來源:Statement.php

示例6: bindParametersFromContainer

 /**
  * Bind parameters from container
  *
  * @return void
  */
 protected function bindParametersFromContainer()
 {
     $parameters = $this->parameterContainer->getNamedArray();
     $type = '';
     $args = array();
     foreach ($parameters as $name => &$value) {
         if ($this->parameterContainer->offsetHasErrata($name)) {
             switch ($this->parameterContainer->offsetGetErrata($name)) {
                 case ParameterContainer::TYPE_DOUBLE:
                     $type .= 'd';
                     break;
                 case ParameterContainer::TYPE_NULL:
                     $value = null;
                     // as per @see http://www.php.net/manual/en/mysqli-stmt.bind-param.php#96148
                 // as per @see http://www.php.net/manual/en/mysqli-stmt.bind-param.php#96148
                 case ParameterContainer::TYPE_INTEGER:
                     $type .= 'i';
                     break;
                 case ParameterContainer::TYPE_STRING:
                 default:
                     $type .= 's';
                     break;
             }
         } else {
             $type .= 's';
         }
         $args[] =& $value;
     }
     if ($args) {
         array_unshift($args, $type);
         call_user_func_array(array($this->resource, 'bind_param'), $args);
     }
 }
開發者ID:Yansor,項目名稱:yafblog,代碼行數:38,代碼來源:Statement.php

示例7: execute

 /**
  * Execute
  *
  * @param  ParameterContainer|null $parameters
  * @throws Exception\InvalidQueryException
  * @return Result
  */
 public function execute($parameters = null)
 {
     if (!$this->isPrepared()) {
         $this->prepare();
     }
     /** START Standard ParameterContainer Merging Block */
     if (!$this->parameterContainer instanceof ParameterContainer) {
         if ($parameters instanceof ParameterContainer) {
             $this->parameterContainer = $parameters;
             $parameters = null;
         } else {
             $this->parameterContainer = new ParameterContainer();
         }
     }
     if (is_array($parameters)) {
         $this->parameterContainer->setFromArray($parameters);
     }
     if ($this->parameterContainer->count() > 0) {
         $parameters = $this->parameterContainer->getPositionalArray();
     }
     /** END Standard ParameterContainer Merging Block */
     if ($this->profiler) {
         $this->profiler->profilerStart($this);
     }
     $resultResource = pg_execute($this->pgsql, $this->statementName, (array) $parameters);
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($resultResource === false) {
         throw new Exception\InvalidQueryException(pg_last_error());
     }
     $result = $this->driver->createResult($resultResource);
     return $result;
 }
開發者ID:idwsdta,項目名稱:INIT-frame,代碼行數:41,代碼來源:Statement.php

示例8: bindParametersFromContainer

 /**
  * Bind parameters from container
  */
 protected function bindParametersFromContainer()
 {
     if ($this->parametersBound) {
         return;
     }
     $parameters = $this->parameterContainer->getNamedArray();
     foreach ($parameters as $name => &$value) {
         if (is_bool($value)) {
             $type = \PDO::PARAM_BOOL;
         } else {
             $type = \PDO::PARAM_STR;
         }
         if ($this->parameterContainer->offsetHasErrata($name)) {
             switch ($this->parameterContainer->offsetGetErrata($name)) {
                 case ParameterContainer::TYPE_INTEGER:
                     $type = \PDO::PARAM_INT;
                     break;
                 case ParameterContainer::TYPE_NULL:
                     $type = \PDO::PARAM_NULL;
                     break;
                 case ParameterContainer::TYPE_LOB:
                     $type = \PDO::PARAM_LOB;
                     break;
             }
         }
         // parameter is named or positional, value is reference
         $parameter = is_int($name) ? $name + 1 : $name;
         $this->resource->bindParam($parameter, $value, $type);
     }
 }
開發者ID:eltonoliveira,項目名稱:jenkins,代碼行數:33,代碼來源:Statement.php

示例9: testRewind

 /**
  * @testdox unit test: Test rewind() resets the iterators pointer
  * @covers Zend\Db\Adapter\ParameterContainer::rewind
  */
 public function testRewind()
 {
     $this->parameterContainer->offsetSet('bar', 'baz');
     $this->parameterContainer->next();
     $this->assertEquals('bar', $this->parameterContainer->key());
     $this->parameterContainer->rewind();
     $this->assertEquals('foo', $this->parameterContainer->key());
 }
開發者ID:rajanlamic,項目名稱:IntTest,代碼行數:12,代碼來源:ParameterContainerTest.php

示例10: processLimitOffset

    /**
     * @param PlatformInterface $platform
     * @param Adapter $adapter
     * @param ParameterContainer $parameterContainer
     * @param $sqls
     * @param $parameters
     * @return null
     */
    protected function processLimitOffset(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters)
    {
        if ($this->limit === null && $this->offset === null) {
            return null;
        }

        $selectParameters = $parameters[self::SPECIFICATION_SELECT];

        $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR;
        foreach ($selectParameters[0] as $i => $columnParameters) {
            if ($columnParameters[0] == self::SQL_STAR || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) || strpos($columnParameters[0], $starSuffix)) {
                $selectParameters[0] = array(array(self::SQL_STAR));
                break;
            }
            if (isset($columnParameters[1])) {
                array_shift($columnParameters);
                $selectParameters[0][$i] = $columnParameters;
            } 
        }

        // first, produce column list without compound names (using the AS portion only)
        array_unshift($sqls, $this->createSqlFromSpecificationAndParameters(
            array('SELECT %1$s FROM (' => current($this->specifications[self::SPECIFICATION_SELECT])),
            $selectParameters
        ));

        if ($parameterContainer) {
            // create bottom part of query, with offset and limit using row_number
            array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?');
            $parameterContainer->offsetSet('offset', $this->offset);
            $parameterContainer->offsetSet('limit', $this->limit);
            $parameterContainer->offsetSetReference('offsetForSum', 'offset');
        } else {
            array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN '
                . (int) $this->offset . '+1 AND '
                . (int) $this->limit . '+' . (int) $this->offset
            );
        }

        if (isset($sqls[self::SPECIFICATION_ORDER])) {
            $orderBy = $sqls[self::SPECIFICATION_ORDER];
            unset($sqls[self::SPECIFICATION_ORDER]);
        } else {
            $orderBy = 'SELECT 1';
        }

        // add a column for row_number() using the order specification
        $parameters[self::SPECIFICATION_SELECT][0][] = array('ROW_NUMBER() OVER (' . $orderBy . ')', '[__ZEND_ROW_NUMBER]');

        $sqls[self::SPECIFICATION_SELECT] = $this->createSqlFromSpecificationAndParameters(
            $this->specifications[self::SPECIFICATION_SELECT],
            $parameters[self::SPECIFICATION_SELECT]
        );

    }
開發者ID:necrogami,項目名稱:zf2,代碼行數:63,代碼來源:SelectDecorator.php

示例11: bindParametersFromContainer

 /**
  * Bind parameters from container
  *
  * @param ParameterContainer $pContainer
  */
 protected function bindParametersFromContainer()
 {
     $parameters = $this->parameterContainer->getNamedArray();
     foreach ($parameters as $name => &$value) {
         if ($this->parameterContainer->offsetHasErrata($name)) {
             switch ($this->parameterContainer->offsetGetErrata($name)) {
                 case ParameterContainer::TYPE_NULL:
                     $type = null;
                     $value = null;
                     break;
                 case ParameterContainer::TYPE_DOUBLE:
                 case ParameterContainer::TYPE_INTEGER:
                     $type = SQLT_INT;
                     if (is_string($value)) {
                         $value = (int) $value;
                     }
                     break;
                 case ParameterContainer::TYPE_BINARY:
                     $type = SQLT_BIN;
                     break;
                 case ParameterContainer::TYPE_LOB:
                     $type = OCI_B_CLOB;
                     $clob = oci_new_descriptor($this->driver->getConnection()->getResource(), OCI_DTYPE_LOB);
                     $clob->writetemporary($value, OCI_TEMP_CLOB);
                     $value = $clob;
                     break;
                 case ParameterContainer::TYPE_STRING:
                 default:
                     $type = SQLT_CHR;
                     break;
             }
         } else {
             $type = SQLT_CHR;
         }
         $maxLength = -1;
         if ($this->parameterContainer->offsetHasMaxLength($name)) {
             $maxLength = $this->parameterContainer->offsetGetMaxLength($name);
         }
         oci_bind_by_name($this->resource, $name, $value, $maxLength, $type);
     }
 }
開發者ID:CHRISTOPHERVANDOMME,項目名稱:zf2complet,代碼行數:46,代碼來源:Statement.php

示例12: processUpdate

 protected function processUpdate(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
 {
     $setSql = [];
     foreach ($this->set as $column => $value) {
         $prefix = $platform->quoteIdentifier($column) . ' = ';
         if (is_scalar($value) && $parameterContainer) {
             $setSql[] = $prefix . $driver->formatParameterName($column);
             $parameterContainer->offsetSet($column, $value);
         } else {
             $setSql[] = $prefix . $this->resolveColumnValue($value, $platform, $driver, $parameterContainer);
         }
     }
     return sprintf($this->specifications[static::SPECIFICATION_UPDATE], $this->resolveTable($this->table, $platform, $driver, $parameterContainer), implode(', ', $setSql));
 }
開發者ID:KBO-Techo-Dev,項目名稱:MagazinePro-zf25,代碼行數:14,代碼來源:Update.php

示例13: processOffset

 protected function processOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
 {
     if ($this->offset === null) {
         return;
     }
     if ($parameterContainer) {
         $parameterContainer->offsetSet('offset', $this->offset, ParameterContainer::TYPE_INTEGER);
         return [$driver->formatParameterName('offset')];
     }
     return [$platform->quoteValue($this->offset)];
 }
開發者ID:kienbk1910,項目名稱:RDCAdmin,代碼行數:11,代碼來源:Select.php

示例14: processSubSelect

 protected function processSubSelect(Select $subselect, PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
 {
     if ($driver) {
         $stmtContainer = new StatementContainer();
         // Track subselect prefix and count for parameters
         $this->processInfo['subselectCount']++;
         $subselect->processInfo['subselectCount'] = $this->processInfo['subselectCount'];
         $subselect->processInfo['paramPrefix'] = 'subselect' . $subselect->processInfo['subselectCount'];
         // call subselect
         if ($this instanceof PlatformDecoratorInterface) {
             /** @var Select|PlatformDecoratorInterface $subselectDecorator */
             $subselectDecorator = clone $this;
             $subselectDecorator->setSubject($subselect);
             $subselectDecorator->prepareStatement(new Adapter($driver, $platform), $stmtContainer);
         } else {
             $subselect->prepareStatement(new Adapter($driver, $platform), $stmtContainer);
         }
         // copy count
         $this->processInfo['subselectCount'] = $subselect->processInfo['subselectCount'];
         $parameterContainer->merge($stmtContainer->getParameterContainer()->getNamedArray());
         $sql = $stmtContainer->getSql();
     } else {
         if ($this instanceof PlatformDecoratorInterface) {
             $subselectDecorator = clone $this;
             $subselectDecorator->setSubject($subselect);
             $sql = $subselectDecorator->getSqlString($platform);
         } else {
             $sql = $subselect->getSqlString($platform);
         }
     }
     return $sql;
 }
開發者ID:tillk,項目名稱:vufind,代碼行數:32,代碼來源:AbstractSql.php

示例15: processOption

 protected function processOption(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
 {
     if (empty($this->option)) {
         return null;
     }
     // process options
     $options = array();
     foreach ($this->option as $optName => $optValue) {
         $optionSql = '';
         if ($optValue instanceof Expression) {
             $parameterPrefix = $this->processInfo['paramPrefix'] . 'option';
             $optionParts = $this->processExpression($optValue, $platform, $driver, $parameterPrefix);
             if ($parameterContainer) {
                 $parameterContainer->merge($optionParts->getParameterContainer());
             }
             $optionSql .= $optionParts->getSql();
         } else {
             if ($driver && $parameterContainer) {
                 $parameterContainer->offsetSet('option_' . $optName, $optValue);
                 $optionSql .= $driver->formatParameterName('option_' . $optName);
             } else {
                 $optionSql .= $platform->quoteValue($optValue);
             }
         }
         $options[] = array($platform->quoteIdentifier($optName), $optionSql);
     }
     return array($options);
 }
開發者ID:joacub,項目名稱:sphinxsearch,代碼行數:28,代碼來源:Update.php


注:本文中的Zend\Db\Adapter\ParameterContainer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。