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


PHP File::open方法代码示例

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


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

示例1: testLastChange

 /**
  * testLastChange method
  *
  * @return void
  */
 public function testLastChange()
 {
     $someFile = new File(TMP . 'some_file.txt', false);
     $this->assertFalse($someFile->lastChange());
     $this->assertTrue($someFile->open('r+'));
     $this->assertWithinRange(time(), $someFile->lastChange(), 2);
     $someFile->write('something');
     $this->assertWithinRange(time(), $someFile->lastChange(), 2);
     $someFile->close();
     $someFile->delete();
 }
开发者ID:Slayug,项目名称:castor,代码行数:16,代码来源:FileTest.php

示例2: _sendFile

 /**
  * Reads out a file, and echos the content to the client.
  *
  * @param File $file File object
  * @param array $range The range to read out of the file.
  * @return bool True is whole file is echoed successfully or false if client connection is lost in between
  */
 protected function _sendFile($file, $range)
 {
     $compress = $this->outputCompressed();
     $file->open('rb');
     $end = $start = false;
     if ($range) {
         list($start, $end) = $range;
     }
     if ($start !== false) {
         $file->offset($start);
     }
     $bufferSize = 8192;
     set_time_limit(0);
     session_write_close();
     while (!feof($file->handle)) {
         if (!$this->_isActive()) {
             $file->close();
             return false;
         }
         $offset = $file->offset();
         if ($end && $offset >= $end) {
             break;
         }
         if ($end && $offset + $bufferSize >= $end) {
             $bufferSize = $end - $offset + 1;
         }
         echo fread($file->handle, $bufferSize);
         if (!$compress) {
             $this->_flushBuffer();
         }
     }
     $file->close();
     return true;
 }
开发者ID:rabinpal,项目名称:cakephp,代码行数:41,代码来源:Response.php

示例3: export


//.........这里部分代码省略.........
         } elseif ($table == 5) {
             $tableName = 'seats';
             $seatsTable = TableRegistry::get('seats');
             $query = $seatsTable->find('all');
             $str = "id" . "," . "theater" . "," . "section" . "," . "row" . "," . "code" . "," . "price\r\n";
             $results = $query->toArray();
             foreach ($results as $item) {
                 $str .= $item->id . ",";
                 $str .= $item->theater_id . ",";
                 $str .= $item->section_id . ",";
                 $str .= $item->row_id . ",";
                 $str .= "\"" . $item->code . "\"" . ",";
                 $str .= $item->price;
                 $str .= "\r\n";
             }
         } elseif ($table == 6) {
             $tableName = 'seasons';
             $seasonsTable = TableRegistry::get('seasons');
             $query = $seasonsTable->find('all');
             $str = "id" . "," . "name" . "," . "start_time" . "," . "end_time" . "," . "ticket_price" . "," . "theater_id" . "\r\n";
             $results = $query->toArray();
             foreach ($results as $item) {
                 $str .= $item->id . ",";
                 $str .= "\"" . $item->name . "\"" . ",";
                 $str .= $item->start_time . ",";
                 $str .= $item->end_time . ",";
                 $str .= $item->ticket_price . ",";
                 $str .= $item->theater_id . ",";
                 $str .= "\"" . $item->about . "\"";
                 $str .= "\r\n";
             }
         } elseif ($table == 7) {
             $tableName = 'rows';
             $rowsTable = TableRegistry::get('rows');
             $query = $rowsTable->find('all');
             $str = "id" . "," . "theater" . "," . "section" . "," . "code\r\n";
             $results = $query->toArray();
             foreach ($results as $item) {
                 $str .= $item->id . ",";
                 $str .= $item->theater_id . ",";
                 $str .= $item->section_id . ",";
                 $str .= "\"" . $item->code . "\"";
                 $str .= "\r\n";
             }
         } elseif ($table == 8) {
             $tableName = 'plays';
             $playsTable = TableRegistry::get('plays');
             $query = $playsTable->find('all');
             $str = "id" . "," . "name" . "," . "artwork" . "," . "description" . "," . "author\r\n";
             $results = $query->toArray();
             foreach ($results as $item) {
                 $str .= $item->id . ",";
                 $str .= "\"" . $item->name . "\"" . ",";
                 $str .= "\"" . $item->artwork . "\"" . ",";
                 $str .= "\"" . $item->description . "\"" . ",";
                 $str .= "\"" . $item->author . "\"" . ",";
                 $str .= "\"" . $item->shortname . "\"";
                 $str .= "\r\n";
             }
         } elseif ($table == 9) {
             $tableName = 'performances';
             $ticketsTable = TableRegistry::get('performances');
             $query = $ticketsTable->find('all');
             $str = "id" . "," . "start_time" . "," . "open" . "," . "canceled" . "," . "play_id" . "," . "theater_id" . "," . "season_id\r\n";
             $results = $query->toArray();
             foreach ($results as $item) {
                 $str .= $item->id . ",";
                 $str .= $item->start_time . ",";
                 $str .= $item->open . ",";
                 $str .= $item->canceled . ",";
                 $str .= $item->play_id . ",";
                 $str .= $item->theater_id . ",";
                 $str .= $item->season_id;
                 $str .= "\r\n";
             }
         } elseif ($table == 10) {
             $tableName = 'cart_items';
             $ticketsTable = TableRegistry::get('cart_items');
             $query = $ticketsTable->find('all');
             $str = "id" . "," . "cart_id" . "," . "performance_id" . "," . "seat_id" . "," . "season_ticket\r\n";
             $results = $query->toArray();
             foreach ($results as $item) {
                 $str .= $item->id . ",";
                 $str .= "\"" . $item->cart_id . "\"" . ",";
                 $str .= "\"" . $item->performance_id . "\"" . ",";
                 $str .= $item->seat_id . ",";
                 $str .= $item->season_id;
                 $str .= "\r\n";
             }
         } else {
             $this->Flash->error('Unexpected table value');
         }
         $file = new File('tmp/', true);
         $file->open('w');
         $file->append($str);
         $this->response->file($file->path, ['download' => true, 'name' => $tableName . '.csv']);
     } else {
         $this->set('file_status', 'Please submit a file.');
     }
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:101,代码来源:SetupAdminController.php


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