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


PHP Prado::serialize方法代码示例

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


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

示例1: save

 public function save($state)
 {
     $content = Prado::serialize($state);
     $saveFile = true;
     if (($cache = $this->getApplication()->getCache()) !== null) {
         if ($cache->get(self::CACHE_NAME) === $content) {
             $saveFile = false;
         } else {
             $cache->set(self::CACHE_NAME, $content);
         }
     }
     if ($saveFile) {
         $fileName = $this->getStateFilePath();
         file_put_contents($fileName, $content, LOCK_EX);
     }
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:16,代码来源:pradolite.php

示例2: serialize

 /**
  * @param TPage
  * @param mixed state data
  * @return string serialized data
  */
 public static function serialize($page, $data)
 {
     $sm = $page->getApplication()->getSecurityManager();
     if ($page->getEnableStateValidation()) {
         $str = $sm->hashData(Prado::serialize($data));
     } else {
         $str = Prado::serialize($data);
     }
     if ($page->getEnableStateCompression() && extension_loaded('zlib')) {
         $str = gzcompress($str);
     }
     if ($page->getEnableStateEncryption()) {
         $str = $sm->encrypt($str);
     }
     return base64_encode($str);
 }
开发者ID:jetbill,项目名称:hospital-universitario,代码行数:21,代码来源:TPage.php

示例3: initApplication

 protected function initApplication()
 {
     if ($this->_configFile !== null) {
         if ($this->_cacheFile === null || @filemtime($this->_cacheFile) < filemtime($this->_configFile)) {
             $config = new TApplicationConfiguration();
             $config->loadFromFile($this->_configFile);
             if ($this->_cacheFile !== null) {
                 file_put_contents($this->_cacheFile, Prado::serialize($config), LOCK_EX);
             }
         } else {
             $config = Prado::unserialize(file_get_contents($this->_cacheFile));
         }
         $this->applyConfiguration($config, false);
     }
     if (($serviceID = $this->getRequest()->resolveRequest(array_keys($this->_services))) === null) {
         $serviceID = $this->getPageServiceID();
     }
     $this->startService($serviceID);
 }
开发者ID:jetbill,项目名称:hospital-universitario,代码行数:19,代码来源:pradolite.php

示例4: addValue

 /**
  * Stores a value identified by a key into cache if the cache does not contain this key.
  * This is the implementation of the method declared in the parent class.
  *
  * @param string the key identifying the value to be cached
  * @param string the value to be cached
  * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
  * @return boolean true if the value is successfully stored into cache, false otherwise
  */
 protected function addValue($key, $value, $expire)
 {
     $expire = $expire <= 0 ? 0 : time() + $expire;
     $sql = 'INSERT INTO ' . self::CACHE_TABLE . ' VALUES(\'' . $key . '\',\'' . sqlite_escape_string(Prado::serialize($value)) . '\',' . $expire . ')';
     return @$this->_db->query($sql) !== false;
 }
开发者ID:bailey-ann,项目名称:stringtools,代码行数:15,代码来源:TSqliteCache.php

示例5: addValue

 /**
  * Stores a value identified by a key into cache if the cache does not contain this key.
  * This is the implementation of the method declared in the parent class.
  *
  * @param string the key identifying the value to be cached
  * @param string the value to be cached
  * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
  * @return boolean true if the value is successfully stored into cache, false otherwise
  */
 protected function addValue($key, $value, $expire)
 {
     if (!$this->_cacheInitialized) {
         $this->initializeCache();
     }
     $expire = $expire <= 0 ? 0 : time() + $expire;
     $sql = "INSERT INTO {$this->_cacheTable} (itemkey,value,expire) VALUES(:key,:value,{$expire})";
     try {
         $command = $this->getDbConnection()->createCommand($sql);
         $command->bindValue(':key', $key, PDO::PARAM_STR);
         $command->bindValue(':value', Prado::serialize($value), PDO::PARAM_LOB);
         $command->execute();
         return true;
     } catch (Exception $e) {
         try {
             $this->initializeCache(true);
             $command->execute();
             return true;
         } catch (Exception $e) {
             return false;
         }
     }
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:32,代码来源:TDbCache.php


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