最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ACCESS数据库向MySQL快速迁移小程序(二)
时间:2022-07-02 21:20:44 编辑:袖梨 来源:一聚教程网
以下为 import.php 源程序
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$dbconnection = @mysql_connect("yourmysqlserver", "mysqlaccount", "mysqlpassword")
or die ("can not connect to database server");
@mysql_select_db("yourdatabase")
or die("
$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" ;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 <= $idcounts ; $i ++) echo "n | " . odbc_field_name($recordsid,$i) ; $theno = 1 ; echo " |