ACCESS数据库向MySQL快速迁移小程序(二)

作者:袖梨 2022-07-02

YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.***w3.org/TR/REC-html40/loose.dtd">

以下为 import.php 源程序
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~









ODBC --> MySQL Migrant







$dbconnection = @mysql_connect("yourmysqlserver", "mysqlaccount", "mysqlpassword")

or die ("can not connect to database server");

@mysql_select_db("yourdatabase")

or die("

No Database,

") ;


$conn = odbc_connect("task", "", "");

$fp = fopen ("fdlist.txt","r") ;

$table1 = fgets($fp,200);

$fd1 = fgets($fp,1024) ;

$table2 = fgets($fp,200);

$fd2 = fgets($fp,1024) ;


$query1 = "select " . $fd1 . " from " . $table1 ;

$query2 = "select " . $fd2 . " from " . $table2 . " where 1=2 " ;

$result = mysql_query ($query2) ;

mysql_query ("delete from " .$table2 ) ;

echo "sql=". $query1;

$recordsid = odbc_exec($conn, $query1);

$idcounts = odbc_num_fields( $recordsid ) ;

$idcount2 = mysql_num_fields($result) ;

if ( $idcounts != $idcount2 )
die (" The fields of two tables doesn't match ") ;

echo "
 n " ;

for ( $i = 1 ; $i
echo "n
" . odbc_field_name($recordsid,$i) ;

$theno = 1 ;

echo "

相关文章

精彩推荐