1 / 14

Introduction to File Processing with PHP

Introduction to File Processing with PHP. 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.

edward
Download Presentation

Introduction to File Processing with PHP

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

  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. File Structures • File Structures are persistent data structures • Files composed of records • Records composed of fields • Files can be viewed as tables • File -> Table • Record -> Row • Field -> Column

  4. File Organization The data is stored as a collection of files. Each file is a sequence of records. A record is a sequence of fields. One approach: assume record size is fixed each file has records of one particular type only this case is easiest to implement; we will consider it further

  5. 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

  6. Fixed-Length Records Simple approach: Store record i starting from byte n  (i – 1), where n is the size of each record. Record access is simple but records may cross blocks Modification: do not allow records to cross block boundaries Ways to delete record i: move records i + 1, . . ., nto i, . . . , n – 1 move record n to i do not move records, but mark deleted record

  7. Variable-Length Records Variable-length records arise in database systems in several ways: Storage of multiple record types in a file. Record types that allow variable lengths for one or more fields such as strings Record types that allow repeating fields (used in some older data models). We won’t talk about VL records

  8. Sequential File Organization For sequential processing of entire file Records ordered by a search-key

  9. Sequential File Organization Deletion – use pointer chains Insertion –locate the position where the record is to be inserted if there is free space insert there if no free space, insert the record in an overflow block In either case, pointer chain must be updated Need to reorganize the file from time to time to restore sequential order

  10. The CRUD paradigm • Open the current version of a file • Process it using the CRUD operations • Create records • Retrieve records • Update records • Delete records • Output and close the new version of the file

  11. 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

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

  13. 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

  14. Some PHP File Tutorials • http://www.tizag.com/phpT/files.php • http://php.about.com/od/advancedphp/ss/php_read_file_5.htm • http://www.codingunit.com/php-tutorial-file-handling

More Related