本文整理汇总了PHP中Zend\Db\Adapter\Platform\PlatformInterface::quoteValue方法的典型用法代码示例。如果您正苦于以下问题:PHP PlatformInterface::quoteValue方法的具体用法?PHP PlatformInterface::quoteValue怎么用?PHP PlatformInterface::quoteValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\Adapter\Platform\PlatformInterface
的用法示例。
在下文中一共展示了PlatformInterface::quoteValue方法的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;
}
示例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($platform->quoteValue($this->offset));
}
}
示例3: 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)];
}
示例4: processLike
/**
* @param PlatformInterface $platform
* @param DriverInterface $driver
* @param ParameterContainer $pContainer
* @return array|null
*/
protected function processLike(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $pContainer = null)
{
if (!$this->like) {
return null;
}
$like = (string) $this->like;
if ($driver && $pContainer) {
$pContainer->offsetSet('like', $like, ParameterContainer::TYPE_STRING);
return array($driver->formatParameterName('like'));
}
return array($platform->quoteValue($like));
}