本文整理汇总了PHP中Illuminate\Redis\Database::command方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::command方法的具体用法?PHP Database::command怎么用?PHP Database::command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Redis\Database
的用法示例。
在下文中一共展示了Database::command方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: command
/**
* Run a command against the Redis database.
*
* @param string $method
* @param array $args
* @return mixed
*/
public final function command($method, array $args = [])
{
if (in_array(strtolower($method), array_keys($this->storeEncoded))) {
$values = $this->storeEncoded[strtolower($method)];
$from = array_get($values, 'from', 0);
$to = array_get($values, 'to', max(0, count($args) - 1));
for ($i = $from; $i <= $to; $i++) {
$args[$i] = $this->encode($args[$i]);
}
}
if ($method == 'mset' || $method == 'msetnx') {
if (count($args) === 1 && is_array($args[0])) {
foreach ($args[0] as $k => $v) {
$args[0][$k] = $this->encode($v);
}
} else {
foreach ($args as $k => $v) {
if ($k % 2 != 0) {
$args[$k] = $this->encode($v);
}
}
}
}
if ($method == 'zadd') {
if (is_array(end($args))) {
foreach (array_pop($args) as $k => $v) {
$args[][$k] = $this->encode($v);
}
} else {
foreach ($arguments as $k => $v) {
if ($k !== 0 && $k % 2 == 0) {
$arguments[$k] = $this->encode($v);
}
}
}
}
if (in_array(strtolower($method), $this->returnDecoded)) {
$result = parent::command($method, $args);
if (is_array($result)) {
return array_map(function ($value) {
return $this->decode($value);
}, $result);
}
return $this->decode($result);
}
return parent::command($method, $args);
}
示例2: command
/**
* Run a command against the Redis database.
*
* @param string $method
* @param array $parameters
* @return mixed
* @static
*/
public static function command($method, $parameters = array())
{
return \Illuminate\Redis\Database::command($method, $parameters);
}