PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

dba_sync> <dba_popen
Last updated: Fri, 10 Oct 2008

view this page in

dba_replace

(PHP 4, PHP 5)

dba_replaceエントリを置換または挿入する

説明

bool dba_replace ( string $key , string $value , resource $handle )

dba_replace() は、handle で 指定したデータベースに key および value で記述されるエントリを 置換または挿入します。

パラメータ

key

置換するエントリのキー。

value

置換される値。

handle

dba_open() あるいは dba_popen() によって返されたデータベースハンドル。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。



dba_sync> <dba_popen
Last updated: Fri, 10 Oct 2008
 
add a note add a note User Contributed Notes
dba_replace
samuele at removethisnorsam dot org
04-Aug-2003 04:23
For a short explanation about disk space usage, see user contrib note at dba_optimize()
jelte dot werkhoven at itfy dot com
26-Sep-2002 07:24
Not only will dba_replace add extra entries when trying to replace an existing smaller one, it will always add a new entry if the size of the value differs from the existing entry. This is probably due to the nature of the datum struct in DBM-type databases (I work with gdbm), which consist of a void pointer and a integer containing the size of the memory pointed to. Padding the value should solve this.
swain at panix dot com
06-Nov-2001 11:03
Note that if you replace an existing entry with a larger one, it will actually create a new entry and the old one is simply lost. This is a memory leak in other words.

You might want to try padding your values to a certain size before putting them in the db file; for example, if you are storing web pages in the db, pad them out to the next 500 byte size with spaces, and strip the spaces when you read it out. This will go a long way in saving disk space. I've seen db files grow to several megabytes with only a couple hundred text files in them.

dba_sync> <dba_popen
Last updated: Fri, 10 Oct 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites