存数据
boolean Module_Storage_Driver_Database::set( string/array $key [, $data $value = null ] )
参数列表
参数 类型 描述 默认值 $key
string/array
支持多存 $value
$data
Value 多存时此项可空 null
boolean
public function set($key, $value = null)
{
if (IS_DEBUG)Core::debug()->info($key, 'database storage set key');
if (is_array($key))
{
foreach ($key as $k=>$v)
{
$k = $this->prefix . $k;
$this->_format_data($value[$k]);
$data = array
(
md5($k),
$k,
$value[$k],
);
$this->_handler->values($data);
}
}
else
{
$key = $this->prefix . $key;
$this->_format_data($value);
$data = array
(
md5($key),
$key,
$value,
);
$this->_handler->values($data);
}
$rs = $this->_handler->columns(array('key', 'key_string', 'value'))->replace($this->tablename);
if ($rs[0])
{
return true;
}
else
{
return false;
}
}