本文整理汇总了PHP中Kohana::serialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::serialize方法的具体用法?PHP Kohana::serialize怎么用?PHP Kohana::serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kohana
的用法示例。
在下文中一共展示了Kohana::serialize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
*
* @param string $key
* @param mixed $value
* @param integer $user_id
* @return boolean
*/
public static function set($key, $value, $user_id = NULL)
{
if ($user_id === NULL) {
$user_id = Auth::get_id();
}
self::_load($user_id);
$value = Kohana::serialize($value);
if (isset(self::$_cache[$user_id][$key])) {
$status = (bool) DB::update('user_meta')->value('value', $value)->where('key', '=', $key)->where('user_id', '=', $user_id === 0 ? NULL : $user_id)->execute();
} else {
$status = (bool) DB::insert('user_meta')->columns(array('key', 'value', 'user_id'))->values(array($key, $value, $user_id === 0 ? NULL : $user_id))->execute();
}
self::_clear_cache($user_id);
return $status;
}
示例2: write
/**
* Writes the passed config for $group
*
* Returns chainable instance on success or throws
* Kohana_Config_Exception on failure
*
* @param string $group The config group
* @param string $key The config key to write to
* @param array $config The configuration to write
* @return boolean
*/
public function write($group, $key, $config)
{
$config = Kohana::serialize($config);
// Check to see if we've loaded the config from the table already
if (isset($this->_loaded_keys[$group][$key])) {
$this->_update($group, $key, $config);
} else {
// Attempt to run an insert query
// This may fail if the config key already exists in the table
// and we don't know about it
try {
$this->_insert($group, $key, $config);
} catch (Database_Exception $e) {
// Attempt to run an update instead
$this->_update($group, $key, $config);
}
}
return TRUE;
}
示例3: update
/**
* Обновление виджета
* При обновлении виджета происходит вызов метода clear_cache()
* для очистки кеша у виджета
*
* @param Widget_Decorator $widget
* @return integer
* @throws HTTP_Exception_404
*/
public static function update(Model_Widget_Decorator $widget)
{
$orm_widget = ORM::factory('widget', $widget->id)->values(array('type' => $widget->type(), 'name' => $widget->name, 'template' => $widget->template, 'description' => $widget->description, 'code' => Kohana::serialize($widget)))->update();
$widget->clear_cache();
return $orm_widget->id;
}
示例4: serialize
/**
*
* @return string
*/
public function serialize()
{
$parameters = array('_primary_key_value', '_object', '_changed', '_loaded', '_saved', '_sorting');
// Store only information about the object
foreach ($parameters as $var) {
$data[$var] = $this->{$var};
}
return Kohana::serialize($data);
}
示例5: update
/**
* Обновление данных поля в БД
*
* Данные которые можно обновить:
*
* * Название {@see header}
* * Ключ {@see name}
* * Параметры {@see _props}
* * Позиция {@see position}
*
* @see DataSource_Hybrid_Field_Factory::update_field()
*
* @return array DB::update
*/
public function update()
{
if (!$this->has_access_edit()) {
throw new DataSource_Hybrid_Exception_Field('You do not have permission to update field');
}
$this->validate();
return DB::update($this->table)->set(array('header' => $this->header, 'props' => Kohana::serialize($this->_props), 'position' => (int) $this->position, 'name' => $this->name, 'from_ds' => (int) $this->from_ds))->where('id', '=', $this->id)->execute();
}
示例6: save_settings
/**
* Сохранение параметров плагина в БД в сериализованном виде
*
* @return \Plugin_Decorator
*/
public function save_settings()
{
$status = (bool) DB::update(Plugin::TABLE_NAME)->set(array('settings' => Kohana::serialize($this->settings())))->where('id', '=', $this->id())->execute();
return $this->_clear_cache();
}
示例7: update
/**
* Обновление раздела.
*
* При сохранении раздела в БД происходит его сериализация и сохарение данных
* в поле "code". Список полей, которые не должын попадать в БД указывается в
* методе {@see _serialize()}
*
* @param array $values
* @throws DataSource_Exception_Section
* @return boolean
*/
public function update()
{
if (!$this->has_access_edit()) {
throw new DataSource_Exception_Section('You do not have permission to update section');
}
if (!$this->loaded()) {
return FALSE;
}
DB::update('datasources')->set(array('indexed' => $this->_is_indexable, 'name' => $this->name, 'description' => $this->description, 'updated_on' => date('Y-m-d H:i:s'), 'created_by_id' => $this->_created_by_id, 'folder_id' => $this->_folder_id, 'code' => Kohana::serialize($this)))->where('id', '=', $this->_id)->execute();
$this->update_size();
Observer::notify('datasource_after_save', $this->_id);
return TRUE;
}
示例8: update
public function update($module, $id, $title, $content = '', $annotation = '', $params = array())
{
$id = (int) $id;
list($header, $content) = $this->_prepare_data($title, $content);
return (bool) DB::update('search_index')->set(array('title' => $title, 'header' => $header, 'content' => $content, 'annotation' => $annotation, 'updated_on' => date('Y-m-d H:i:s'), 'params' => Kohana::serialize($params)))->where('module', '=', $module)->where('id', '=', $id)->execute();
}
示例9: _create_site_config
/**
* Запись в БД данных в таблицу config
* Значения по умолчанию устанавливаются в конфиг файле `installer`
*
* @param array $post
*/
protected function _create_site_config(array $post)
{
$config_values = $this->_config->get('default_config', array());
$config_values['site']['title'] = Arr::get($post, 'site_name');
$config_values['site']['date_format'] = Arr::get($post, 'date_format');
$config_values['site']['default_locale'] = Arr::get($post, 'locale');
$config_values['email']['default'] = Arr::get($post, 'email');
$insert = DB::insert('config', array('group_name', 'config_key', 'config_value'));
foreach ($config_values as $group => $data) {
foreach ($data as $key => $config) {
$insert->values(array($group, $key, Kohana::serialize($config)));
}
}
$insert->execute($this->_db_instance);
}
示例10: activate
/**
* Активация плагина
*
* При инсталляции плагина происходит добавление плагина в `Kohana::modules()`,
* запуск SQL из файла `plugin_path/install/schema.sql` и запуск файла
* `plugin_path/install.php`
*
* @observer plugin_install
* @return \Plugin_Decorator
*/
public function activate()
{
if (!$this->is_installable()) {
throw new Plugin_Exception('Plugin can not be installed. The required version of the CMS: :required_version. Version of your CMS is: :current_version.', array(':required_version' => $this->required_cms_version(), ':current_version' => CMS_VERSION));
}
$data = array('id' => $this->id(), 'title' => $this->title(), 'settings' => Kohana::serialize($this->settings()));
$result = DB::insert(self::TABLE_NAME)->columns(array_keys($data))->values($data)->execute();
Kohana::modules(Kohana::modules() + array('plugin_' . $this->id() => PLUGPATH . $this->id()));
$this->_clear_cache();
$schema_file = $this->path() . 'install' . DIRECTORY_SEPARATOR . 'schema.sql';
if (file_exists($schema_file)) {
Database_Helper::insert_sql(file_get_contents($schema_file));
}
$install_file = $this->path() . 'install' . EXT;
if (file_exists($install_file)) {
Kohana::load($install_file);
}
Observer::notify('plugin_install', $this->id());
$this->_on_activate();
Plugins::activate($this);
}