1 / 17

Introduction to File Processing with PHP - Part 2 Indexed Files

Introduction to File Processing with PHP - Part 2 Indexed Files. Review of Course Outcomes. 1 . Implement file reading and writing programs using PHP. 2. Identify file access schemes, including: sequential file access direct file access indexed sequential file access.

misu
Download Presentation

Introduction to File Processing with PHP - Part 2 Indexed Files

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to File Processing with PHP - Part 2 Indexed Files

  2. Review of Course Outcomes 1. Implement file reading and writing programs using PHP. 2. Identify file access schemes, including: sequentialfile access direct file access indexed sequential file access. 3. Describe file-sorting and file-searching techniques. 4. Describe data compression and encryption techniques. 5. Design a rational database using E-R modeling techniques. 6. Build a relational database. 7. Write database queries using SQL. 8. Implement a web-based relational database using MySQL.

  3. Organization of Records in Files Heap – a record can be placed anywhere in the file where there is space Sequential – store records in sequential order, perhaps based on the value of the search key of each record Indexing – Keep two files, the Data File and an Index File and the data file. Index records hold file pointers of Data records Hashing – a hash function computed on some attribute of each record; the result specifies in which block of the file the record should be placed

  4. Implementing CRUD paradigm in PHP • Use PHP file functions • There a many of them • We will start with a simple subset that are similar to file functions used in C and in other C-based languages

  5. The PHP filesystem functions • http://us2.php.net/manual/en/ref.filesystem.php

  6. A C-like subset • fopen • http://us2.php.net/manual/en/function.fopen.php • fgets • http://us2.php.net/manual/en/function.fgets.php • fwrite • http://us2.php.net/manual/en/function.fwrite.php • fclose • http://us2.php.net/manual/en/function.fclose.php

  7. To Open a File for Processing resource fopen ( string $filename , string $mode [, bool $use_include_path = false [, resource $context ]] )

  8. Mode Codes

  9. Read a string from a file string fgets ( resource $handle [, int $length ] )

  10. Write a string to a file intfwrite ( resource $handle , string $string [, int $length ] )

  11. Close a file to processing boolfclose ( resource $handle )

  12. Test if a file is at the end boolfeof ( resource $handle )

  13. Move the file pointer intfseek ( resource $handle , int $offset [, int $whence = SEEK_SET ] )

  14. Read a string string fread ( resource $handle , int $length )

  15. Read an entire file array file ( string $filename [, int $flags = 0 [, resource $context ]] )

  16. Read an entire file string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] )

  17. Write to a file intfile_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] )

More Related