PHP Classes

Proposal of improvement

Recommend this page to a friend!

      Random Access File  >  All threads  >  Proposal of improvement  >  (Un) Subscribe thread alerts  
Subject:Proposal of improvement
Summary:a new parameter : length of header
Messages:8
Author:Dantigny francois
Date:2016-07-09 12:00:00
 

  1. Proposal of improvement   Reply   Report abuse  
Picture of Dantigny francois Dantigny francois - 2016-07-09 12:00:00
Certain database have records with fixed lengthes but besides a header. (Dbase III, IV for example). The addition of a parameter specifying the length of this header will be a good idea to have habiilty to trasfert a kind of database in an other. (sorry for my english spoken)

  2. Re: Proposal of improvement   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-07-09 12:13:06 - In reply to message 1 from Dantigny francois
This is an excellent and very useful suggestion ! I will implement it within the next few days, together with the naive cache algorithm I implemented in the SearchableFile class.

Thanks again for your idea !

  3. Re: Proposal of improvement   Reply   Report abuse  
Picture of Dantigny francois Dantigny francois - 2016-07-09 18:00:18 - In reply to message 2 from Christian Vigh
Thanks to you : I knzw this problem when I transfer an old dBase III database in an SQLITE database ;) For information, the size (length) of the header = 32 * number of columns.

  4. Re: Proposal of improvement   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-07-09 19:14:50 - In reply to message 3 from Dantigny francois
Thanks for the information.

I will implement a $header_size parameter in the constructor, along with a GetHeader() method and "Header"/"HeaderSize" properties.

My idea of a GetHeader() method is just for the case where the header length is variable and its size would be contained in a fixed part of the header itself.

This would allow derived classes to override GetHeader() to get the real header size in this case. Of course, implementing a GetHeader() derived method would be completely optional if you already know the size of the header.

Would it be ok for you ?

  5. Re: Proposal of improvement   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-07-13 13:10:32 - In reply to message 3 from Dantigny francois
Hello François,

I made the changes according to your proposal.

The class is now able to handle random access files having a header at the beginning.

It can handle two situations :
- The caller already knows the size of the header : in this case, he can specify this size as the (new) third parameter of the class constructor, $header_size
- The caller does not know the size of the header, which may be specified in some fixed-part of the header itself. In this case the caller can specified a callback function instead of an integer value for the $header_size parameter. This function will be called whenever the Open() method will be called, and will allow the caller to extract header size information from the file and return it to the class.

I have added two examples, example-with-fixed-header.php and example-with-variable-header..php, which illustrate the above situations.

Please let me know if it fits your needs.

  6. Re: Proposal of improvement   Reply   Report abuse  
Picture of Dantigny francois Dantigny francois - 2016-07-15 14:43:16 - In reply to message 5 from Christian Vigh
Fine ! thanks

  7. Re: Proposal of improvement   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-07-15 14:51:21 - In reply to message 6 from Dantigny francois
Perfect ! please feel free to contact me if you have any issues...

  8. Re: Proposal of improvement   Reply   Report abuse  
Picture of Dantigny francois Dantigny francois - 2016-07-15 16:09:57 - In reply to message 7 from Christian Vigh
No trouble !