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


PHP File::read方法代码示例

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


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

示例1: model

 public function model($data = [])
 {
     $view = false;
     $db = $this->db;
     $table = $this->table;
     $modelFile = APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models' . DS . Inflector::lower($db) . DS . ucfirst(Inflector::lower($table)) . '.php';
     if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql')) {
         File::mkdir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql');
     }
     if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models')) {
         File::mkdir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models');
     }
     if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models' . DS . Inflector::lower($db))) {
         File::mkdir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models' . DS . Inflector::lower($db));
     }
     if (!File::exists($modelFile)) {
         File::put($modelFile, str_replace('##class##', ucfirst(Inflector::lower($db)) . ucfirst(Inflector::lower($table)) . 'SQLModel', File::read(__DIR__ . DS . 'dbModel.tpl')));
     }
     $class = '\\Thin\\' . ucfirst(Inflector::lower($db)) . ucfirst(Inflector::lower($table)) . 'SQLModel';
     if (!class_exists($class)) {
         require_once $modelFile;
     }
     $model = $this;
     if (true === $view) {
         $model = self::instance($db, $table);
     }
     return new $class($model, $data);
 }
开发者ID:schpill,项目名称:standalone,代码行数:28,代码来源:Db.php

示例2: get

 public function get($key, $default = null)
 {
     $key = $this->key($key);
     $this->clean();
     $file = $this->getFile($key);
     if (File::exists($file)) {
         return unserialize(File::read($file));
     }
     return $default;
 }
开发者ID:schpill,项目名称:standalone,代码行数:10,代码来源:Caching.php

示例3: read

 public function read($file)
 {
     $key = $this->redisKey($file);
     $cache = $this->model->cache()->get($key);
     if (!strlen($cache)) {
         if (File::exists($file)) {
             $cache = File::read($file);
             $this->model->cache()->set($key, $cache);
         }
     }
     return $cache;
 }
开发者ID:schpill,项目名称:standalone,代码行数:12,代码来源:Redis.php

示例4: bag

 public function bag($k, $data = [])
 {
     $key = sha1($this->getIdentifier() . $k);
     $file = '/home/php/storage/bag/' . $key;
     $data = array_merge($data, ['id' => $key]);
     if (file_exists($file)) {
         $data = array_merge($data, unserialize(File::read($file)));
     }
     return dyn(lib('model', [$data]))->extend('save', function ($app) use($file, $k) {
         $row = $app->getNative()->toArray();
         File::delete($file);
         File::put($file, serialize($row));
         return bag($k);
     })->extend('delete', function ($app) use($file) {
         return File::delete($file);
     });
 }
开发者ID:schpill,项目名称:standalone,代码行数:17,代码来源:clipp.php

示例5: read

 public function read($id, $default = null)
 {
     $key = $this->key . '::' . $id;
     try {
         $result = $this->client->getObject(array('Bucket' => $this->bucket, 'Key' => $key));
     } catch (NoSuchKeyException $e) {
         if (!strstr($id, 'file::')) {
             $data = File::read($this->findFile($id));
         } else {
             $data = File::read(str_replace('thinseparator', '', str_replace('file::', '', $id)));
         }
         if (strlen($data)) {
             $this->write($id, $data);
             return $data;
         } else {
             return $default;
         }
     }
     return $result['Body'];
 }
开发者ID:schpill,项目名称:standalone,代码行数:20,代码来源:S3.php

示例6: read

 public function read($id, $default = null)
 {
     $key = $this->key . '::' . $id;
     $row = $this->collection->findOne(function ($query) use($key) {
         $query->where('key', $key);
     });
     if ($row) {
         return isAke($row, 'value', $default);
     } else {
         if (!strstr($id, 'file::')) {
             $data = File::read($this->findFile($id));
         } else {
             $data = File::read(str_replace('thinseparator', '', str_replace('file::', '', $id)));
         }
         if (strlen($data)) {
             $this->write($id, $data);
             return $data;
         } else {
             return $default;
         }
     }
     return $default;
 }
开发者ID:schpill,项目名称:standalone,代码行数:23,代码来源:Mongo.php

示例7: hgetall

 public function hgetall($h)
 {
     $dirH = self::$dir . DS . $h;
     if (!is_dir($dirH)) {
         umask(00);
         mkdir($dirH, 0777);
     }
     $keys = glob($dirH . DS . '*', GLOB_NOSORT);
     $collection = [];
     if (count($keys)) {
         foreach ($keys as $cache) {
             $k = str_replace('.cache', '', Arrays::last(explode(DS, $cache)));
             $collection[$k] = unserialize(File::read($cache));
         }
     }
     return $collection;
 }
开发者ID:schpill,项目名称:standalone,代码行数:17,代码来源:Cache.php

示例8: upload

 public function upload($field)
 {
     $bucket = new Bucket(SITE_NAME, 'http://zelift.com/bucket');
     if (Arrays::exists($field, $_FILES)) {
         $fileupload = $_FILES[$field]['tmp_name'];
         $fileuploadName = $_FILES[$field]['name'];
         if (strlen($fileuploadName)) {
             $tab = explode(".", $fileuploadName);
             $data = File::read($fileupload);
             if (!strlen($data)) {
                 return null;
             }
             $ext = strtolower(end($tab));
             $res = $bucket->data($data, $ext);
             return $res;
         }
     }
     return false;
 }
开发者ID:schpill,项目名称:standalone,代码行数:19,代码来源:form.php

示例9: getFieldValueById

 public function getFieldValueById($field, $id, $d = null)
 {
     return isAke(unserialize(File::read($this->db->dir . DS . $id)), $field, $d);
 }
开发者ID:schpill,项目名称:standalone,代码行数:4,代码来源:flight.php

示例10: importCsvFile

 public function importCsvFile($csv, $delimiter = '|||')
 {
     return $this->importCsvData(File::read($csv), $delimiter);
 }
开发者ID:schpill,项目名称:standalone,代码行数:4,代码来源:Dbjson.php

示例11: hvals

 public function hvals($hash)
 {
     $glob = glob($this->dir . DS . 'hash.' . $hash . DS . '*.store', GLOB_NOSORT);
     foreach ($glob as $row) {
         if (fnmatch('*expire.*', $row)) {
             continue;
         }
         (yield unserialize(File::read($row)));
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:10,代码来源:store.php

示例12: clean

 public function clean()
 {
     $glob = glob($this->dir . DS . 'expire.', GLOB_NOSORT);
     foreach ($glob as $row) {
         $row = str_replace([$this->dir . DS, '.raw'], '', $row);
         list($d, $key) = explode('expire.', $row, 2);
         $expire = $this->getFile($row);
         $expiration = (int) unserialize(File::read($expire));
         if (time() > $expiration) {
             $file = $this->getFile($key);
             File::delete($expire);
             File::delete($file);
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:15,代码来源:Store.php

示例13: makeCompile

 protected function makeCompile($file)
 {
     $route = container()->getRoute();
     $module = !isset($route->module) ? 'default' : $route->module;
     $content = File::read($file);
     if (strstr($content, '@@layout')) {
         $layout = Utils::cut("@@layout('", "')", $content);
         $layoutFile = APPLICATION_PATH . DS . 'modules' . DS . SITE_NAME . DS . $module . DS . 'views' . DS . 'layouts' . DS . $layout . '.phtml';
         $layoutFile2 = APPLICATION_PATH . DS . 'modules' . DS . $module . DS . 'views' . DS . 'layouts' . DS . $layout . '.phtml';
         if (File::exists($layoutFile)) {
             $contentL = File::read($layoutFile);
             $content = str_replace('@@content', str_replace("@@layout('{$layout}')", '', $content), $contentL);
         } else {
             if (File::exists($layoutFile2)) {
                 $contentL = File::read($layoutFile2);
                 $content = str_replace('@@content', str_replace("@@layout('{$layout}')", '', $content), $contentL);
             }
         }
     }
     $content = repl('<php>', '<?php ', $content);
     $content = repl('<php>=', '<?php echo ', $content);
     $content = repl('</php>', '?>', $content);
     $content = repl('{{=', '<?php echo ', $content);
     $content = repl('{{', '<?php ', $content);
     $content = repl('}}', '?>', $content);
     $content = repl('<?=', '<?php echo ', $content);
     $content = repl('<? ', '<?php ', $content);
     $content = repl('<?[', '<?php [', $content);
     $content = repl('[if]', 'if ', $content);
     $content = repl('[elseif]', 'elseif ', $content);
     $content = repl('[else if]', 'else if ', $content);
     $content = repl('[else]', 'else:', $content);
     $content = repl('[/if]', 'endif;', $content);
     $content = repl('[for]', 'for ', $content);
     $content = repl('[foreach]', 'foreach ', $content);
     $content = repl('[while]', 'while ', $content);
     $content = repl('[switch]', 'switch ', $content);
     $content = repl('[/endfor]', 'endfor;', $content);
     $content = repl('[/endforeach]', 'endforeach;', $content);
     $content = repl('[/endwhile]', 'endwhile;', $content);
     $content = repl('[/endswitch]', 'endswitch;', $content);
     $content = repl('$this->partial(', 'context("view")->partial(', $content);
     $content = repl('$this->tpl(', 'context("view")->partial(', $content);
     $content = repl('includes(', 'context("view")->partial(', $content);
     if (count($this->_grammar)) {
         foreach ($this->_grammar as $grammar => $replace) {
             $content = repl($grammar, $replace, $content);
         }
     }
     $base_uri = Config::get('application.base_uri', '');
     $content = repl(array('src="/', 'href="/', 'action="/'), array('src="/' . $base_uri, 'href="/' . $base_uri, 'action="/' . $base_uri), $content);
     return $content;
 }
开发者ID:schpill,项目名称:thin,代码行数:53,代码来源:View.php

示例14: delete

 public function delete($k)
 {
     $tab = $this->unserialize(File::read($this->file));
     unset($tab[$k]);
     File::delete($this->file);
     File::put($this->file, $this->serialize($tab));
     return $this;
 }
开发者ID:schpill,项目名称:standalone,代码行数:8,代码来源:memcache.php

示例15: makeId

 private function makeId()
 {
     $file = $this->dir . DS . 'lastid.blazz';
     if (is_file($file)) {
         $last = File::read($file);
         $new = $last + 1;
         File::delete($file);
         File::put($file, $new);
         return $new;
     }
     File::put($file, 1);
     return 1;
 }
开发者ID:schpill,项目名称:standalone,代码行数:13,代码来源:blazz.php


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