Re: Suggestion for dbm functions
| From: | Sascha Schumann | Date: | Wed, 03 Mar 1999 14:56:10 +0000 |
| Subject: | Re: Suggestion for dbm functions | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-4457@lists.php.net to get a copy of this message | ||
On Wed, Mar 03, 1999 at 09:35:23AM +0100, Lars Christensen wrote:
> On Tue, 2 Mar 1999, Rasmus Lerdorf wrote:
>
> > > I suggest thet the two functions dbmstore and dbmfetch take any variably
> > > type as parameter instead of only strings so that you can store any data
> > > type, even arrays and objects. This would indeed make the dbm functions
> > > usable for more purposes.
You would run into many platform-dependent problems. Strings are an easy and
flexible way to represent data. You can throw them at every relational
database, flatfile or use it at the command line.
> > > I have only gdbm available here, but from the documentation supplied, I
> > > know that you can easily store binary data and not just strings.
> > >
> > > Making this change would even not break existing php3 sources, as strings
> > > would still be strings.
Ah, not really.
$a = 5;
store(..., $a);
store will convert_to_string($a) before storing it. If the function would be
changed as you propose, this would save a binary representation of the number.
> > I don't think it makes much sense to make this specific to the dbm
> > functions. There are already functions that take any PHP data structure
> > and convert it to a string and back. See the serialize() function, for
> > example.
>
> Well, much space could be saved by using a binary representation instead
> of the string representation. Also, parsing a string must be less
> efficient. Finally, the format that serialize() uses seems for me to have
> much overhead. An array of 6 integers take up (at least) 50 bytes. That is
> when I use small integer values. Higher values (10 digit for example)
> makes the overhead would be much worse.
You can always pack() it yourself. Is the size of the data really that
important? Then it is time to hook up some compression library into PHP3.
--
Regards,
Sascha Schumann |
Consultant | finger sas@schell.de
| for PGP public key
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net