Writing to dbase (dbf) deletes index (cdx)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ave,

I noticed something peculiar and I can't find a solution for this. I'm wondering if anyone can help me out.

I'm using the dbase functions to read & write from dbf (foxpro) tables. The DBF tables usually have an Index which is contained in filename.cdx. It appears that anytime I Write to the dbf table, it deletes the Index. Is there any way around this?

Here's a simple code that I use for appending to a DBF table:

// open in read-write mode
$db = dbase_open("dbf/myfile.dbf", 2);
		
 // gets the old row
if ($db) {
	  $record_numbers = dbase_numrecords($db);
		  for ($i = 1; $i <= $record_numbers; $i++) {
			 $row = dbase_get_record_with_names($db, $i);
			 if ($row['SECCODE'] == $_COOKIE['seccodeCookie']) {
			
			  unset($row["deleted"]); 			
			  // Update fields	
			
			  $row['f1'] = $_POST['name'];
			  $row['f2'] = $_POST['email'];		
			
			  //echo "Replacing Record number $i";
			  // Replace the record
			  $row = array_values($row);
			  dbase_replace_record($db, $row, $i) or die("Fatal Error");
			  }
		  }
	}
dbase_close($db);
?>

Thanks.

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email]	sleepwalker@xxxxxxxxxxxxxxxx
[Web]	http://www.rahulsjohari.com





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux