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


PHP PlatformInterface::quoteIdentifierInFragment方法代码示例

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


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

示例1: processExpression

    protected function processExpression(ExpressionInterface $expression, PlatformInterface $platform, DriverInterface $driver = null, $namedParameterPrefix = null)
    {
        // static counter for the number of times this method was invoked across the PHP runtime
        static $runtimeExpressionPrefix = 0;

        if ($driver && ((!is_string($namedParameterPrefix) || $namedParameterPrefix == ''))) {
            $namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix);
        }

        $return = array(
            'sql' => '',
            'parameters' => array()
        );

        // initialize variables
        $parts = $expression->getExpressionData();
        $expressionParamIndex = 1;

        foreach ($parts as $part) {

            // if it is a string, simply tack it onto the return sql "specification" string
            if (is_string($part)) {
                $return['sql'] .= $part;
                continue;
            }

            if (!is_array($part)) {
                throw new Exception\RuntimeException('Elements returned from getExpressionData() array must be a string or array.');
            }

            // process values and types (the middle and last position of the expression data)
            $values = $part[1];
            $types = (isset($part[2])) ? $part[2] : array();
            foreach ($values as $vIndex => $value) {
                if (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_IDENTIFIER) {
                    $values[$vIndex] = $platform->quoteIdentifierInFragment($value);
                } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE) {

                    // if prepareType is set, it means that this particular value must be
                    // passed back to the statement in a way it can be used as a placeholder value
                    if ($driver) {
                        $name = $namedParameterPrefix . $expressionParamIndex++;
                        $return['parameters'][$name] = $value;
                        $values[$vIndex] = $driver->formatParameterName($name);
                        continue;
                    }

                    // if not a preparable statement, simply quote the value and move on
                    $values[$vIndex] = $platform->quoteValue($value);
                } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_LITERAL) {
                    $values[$vIndex] = $value;
                }
            }

            // after looping the values, interpolate them into the sql string (they might be placeholder names, or values)
            $return['sql'] .= vsprintf($part[0], $values);
        }

        return $return;
    }
开发者ID:necrogami,项目名称:zf2,代码行数:60,代码来源:AbstractSql.php

示例2: processExpression

 protected function processExpression(ExpressionInterface $expression, PlatformInterface $platform, DriverInterface $driver = null, $namedParameterPrefix = null)
 {
     // static counter for the number of times this method was invoked across the PHP runtime
     static $runtimeExpressionPrefix = 0;
     if ($driver && (!is_string($namedParameterPrefix) || $namedParameterPrefix == '')) {
         $namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix);
     }
     $sql = '';
     $statementContainer = new StatementContainer();
     $parameterContainer = $statementContainer->getParameterContainer();
     // initialize variables
     $parts = $expression->getExpressionData();
     if (!isset($this->instanceParameterIndex[$namedParameterPrefix])) {
         $this->instanceParameterIndex[$namedParameterPrefix] = 1;
     }
     $expressionParamIndex =& $this->instanceParameterIndex[$namedParameterPrefix];
     foreach ($parts as $part) {
         // if it is a string, simply tack it onto the return sql "specification" string
         if (is_string($part)) {
             $sql .= $part;
             continue;
         }
         if (!is_array($part)) {
             throw new Exception\RuntimeException('Elements returned from getExpressionData() array must be a string or array.');
         }
         // process values and types (the middle and last position of the expression data)
         $values = $part[1];
         $types = isset($part[2]) ? $part[2] : array();
         foreach ($values as $vIndex => $value) {
             if (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_IDENTIFIER) {
                 $values[$vIndex] = $platform->quoteIdentifierInFragment($value);
             } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE && $value instanceof Select) {
                 // process sub-select
                 if ($driver) {
                     $values[$vIndex] = '(' . $this->processSubSelect($value, $platform, $driver, $parameterContainer) . ')';
                 } else {
                     $values[$vIndex] = '(' . $this->processSubSelect($value, $platform) . ')';
                 }
             } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE && $value instanceof ExpressionInterface) {
                 // recursive call to satisfy nested expressions
                 $innerStatementContainer = $this->processExpression($value, $platform, $driver, $namedParameterPrefix . $vIndex . 'subpart');
                 $values[$vIndex] = $innerStatementContainer->getSql();
                 if ($driver) {
                     $parameterContainer->merge($innerStatementContainer->getParameterContainer());
                 }
             } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE) {
                 // if prepareType is set, it means that this particular value must be
                 // passed back to the statement in a way it can be used as a placeholder value
                 if ($driver) {
                     $name = $namedParameterPrefix . $expressionParamIndex++;
                     $parameterContainer->offsetSet($name, $value);
                     $values[$vIndex] = $driver->formatParameterName($name);
                     continue;
                 }
                 // if not a preparable statement, simply quote the value and move on
                 $values[$vIndex] = $platform->quoteValue($value);
             } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_LITERAL) {
                 $values[$vIndex] = $value;
             }
         }
         // after looping the values, interpolate them into the sql string (they might be placeholder names, or values)
         $sql .= vsprintf($part[0], $values);
     }
     $statementContainer->setSql($sql);
     return $statementContainer;
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:66,代码来源:AbstractSql.php

示例3: processOrder

 protected function processOrder(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null)
 {
     if (empty($this->order)) {
         return null;
     }
     $orders = array();
     foreach ($this->order as $k => $v) {
         if (is_int($k)) {
             if (strpos($v, ' ') !== false) {
                 list($k, $v) = preg_split('# #', $v, 2);
             } else {
                 $k = $v;
                 $v = self::ORDER_ASCENDING;
             }
         }
         if (strtoupper($v) == self::ORDER_DESCENDING) {
             $orders[] = array($platform->quoteIdentifierInFragment($k), self::ORDER_DESCENDING);
         } else {
             $orders[] = array($platform->quoteIdentifierInFragment($k), self::ORDER_ASCENDING);
         }
     }
     return array($orders);
 }
开发者ID:Rovak,项目名称:zf2,代码行数:23,代码来源:Select.php

示例4: processJoin

    protected function processJoin(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null)
    {
        if (!$this->joins) {
            return null;
        }

        // process joins
        $joinSpecArgArray = array();
        foreach ($this->joins as $j => $join) {
            $joinSpecArgArray[$j] = array();
            $joinSpecArgArray[$j][] = strtoupper($join['type']); // type
            $joinSpecArgArray[$j][] = $platform->quoteIdentifier($join['name']); // table
            $joinSpecArgArray[$j][] = $platform->quoteIdentifierInFragment($join['on'], array('=', 'AND', 'OR', '(', ')')); // on
        }

        return array($joinSpecArgArray);
    }
开发者ID:necrogami,项目名称:zf2,代码行数:17,代码来源:Select.php


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