本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
});
}
示例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'];
}
示例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;
}
示例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;
}
示例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;
}
示例9: getFieldValueById
public function getFieldValueById($field, $id, $d = null)
{
return isAke(unserialize(File::read($this->db->dir . DS . $id)), $field, $d);
}
示例10: importCsvFile
public function importCsvFile($csv, $delimiter = '|||')
{
return $this->importCsvData(File::read($csv), $delimiter);
}
示例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)));
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}