php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4406 ODBC updates to dBase4 files aren't reflected in index file so changes are gone
Submitted: 2000-05-11 14:58 UTC Modified: 2001-02-10 16:18 UTC
From: robert dot wadsworth at cache dot k12 dot ut dot us Assigned:
Status: Closed Package: ODBC related
PHP Version: 3.0.16 OS: WinNT4.0 server,IIS4,SP6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: robert dot wadsworth at cache dot k12 dot ut dot us
New email:
PHP Version: OS:

 

 [2000-05-11 14:58 UTC] robert dot wadsworth at cache dot k12 dot ut dot us
The problem I have found occurs when using ODBC for insertions/deletions into a dBase4 table.  (I am using MS ODBC DBase driver version 3.51.102900 ODBCJT32.DLL).  I do not know if the problem is occurring from PHP or from the Microsoft ODBC driver. (I am using ODBC for the multi-thread support, don't really want to use non-threaded PHP DBase functions)

The sample code below was run on an empty table (as well as a populated table) in both cases the new records were in the dbase4 DBF file, but not accessable until the MDX file was manually rebuilt.  Since the new record is in the DBF file and PHP isn't retrieving it until the index file is rebuilt, I think that PHP is correctly using the index file to access the dbase4 DBF file, but I don't know why the MDX file is not being updated.  Both PHP and MS ODBC information say that with Dbase4/5 files the MDX files are automatically linked and updated.  I believe they are being linked  for reading, but the MDX is not being updated after delete or write.

ANY help would be greatly appreciated!

Robert

----sample code
<?
function Error_Handler( $msg, $cnx )
{
 echo "<font color=\"#FF0000\">$msg </font>\n";
 odbc_close( $cnx);
 exit();
}
function Get_SQLDateformat( $date )
{
  $y=substr($date,0,4);
  $m=substr($date,4,2);
  $d=substr($date,6,2);
  $newdate="$y-$m-$d";  	 
  return($newdate);
}
function addrecord_table()
{
	$cnx = odbc_connect( "sasiDB" , '', '');
  if( ! $cnx )
  {
    Error_handler( "Error in odbc_connect" , $cnx );
  }
  //INSERT INTO ANTIQUES (BUYERID, SELLERID, ITEM) VALUES (01, 21, 'Ottoman');
  //echo "INSERT INTO $table (STULINK,STARTDT,ENDDT,MEMBERSHIP) VALUES ($stulink,'$startdt','$enddt','$membership')";
  //$cur= odbc_exec( $cnx, "INSERT INTO $table (STULINK,STARTDT,ENDDT,MEMBERSHIP) VALUES ('$stulink',$startdt,$enddt,'$membership')" );
 // $sd=Get_SQLDateformat($startdt);
 // $ed=Get_SQLDateformat($enddt);
  $stulink="1510";
  $sd="2000-06-01";
  $ed="2000-06-02";
  $membership=2;
  $table="USMB9320";
  echo "<BR>Insert Query: INSERT INTO $table (STULINK,STARTDT,ENDDT,MEMBERSHIP) VALUES ($stulink,$sd,$ed,$membership)<BR>";
  $cur= odbc_exec( $cnx, "INSERT INTO $table (STULINK,STARTDT,ENDDT,MEMBERSHIP) VALUES ($stulink,$sd,$ed,$membership)" );  if( ! $cur )
  {
    Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
  }
  echo "Inserted $cur fields to $table - Done<BR>\n";
  odbc_commit( $cnx);
   odbc_close( $cnx);
}

function dump_table()
{
  echo "<BR><BR>";
	$cnx = odbc_connect( "sasiDB" , '', '');
  if( ! $cnx )
  {
    Error_handler( "Error in odbc_connect" , $cnx );
  }
  $cur= odbc_exec( $cnx, "SELECT * FROM USMB9325" );
  echo "Dumping Table<BR>";
  echo "SELECT * FROM $table  CUR:$cur  <BR>";
  if( ! $cur )
  {
    Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
  }  
  $nf=odbc_num_fields($cur);
  echo "NF: $nf  <BR>";
  for($i=1;$i<=$nf;$i++)
   {
     $f[$i]= odbc_field_name( $cur, $i ); // get the field 
     echo "$f[$i]  ";
   }
  echo "<BR>\n"; 
  while( odbc_fetch_row( $cur ) )
  {  	
   for($i=1;$i<=$nf;$i++)
   {
     $rec[$i]= odbc_result( $cur, $i ); // get the field 
     echo "$rec[$i]  ";
   }  
   echo "<BR>";
  }  
 
   odbc_close( $cnx);
}
  
dump_table();
addrecord_table();
dump_table();

?>


------from php3.ini------
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
; if you wish to have an extension loaded automaticly, use the
; following syntax:  extension=modulename.extension
; for example, on windows,
; extension=msql.dll
; or under UNIX,
; extension=msql.so
; Note that it should be the name of the module only, no directory information 
; needs to go here.  Specify the location of the extension with the extension_dir directive above.


;Windows Extensions
;extension=php3_mysql.dll
;extension=php3_calendar.dll
extension=php3_dbase.dll
;extension=php3_gd.dll
;extension=php3_dbm.dll
;extension=php3_mssql.dll
;extension=php3_zlib.dll
;extension=php3_filepro.dll
;extension=php3_imap4r1.dll
;extension=php3_ldap.dll
;extension=php3_crypt.dll
;extension=php3_msql2.dll
extension=php3_odbc.dll

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-10 16:18 UTC] jimw@php.net
sounds like a problem with the odbc dbase driver.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 02:01:30 2024 UTC