ACCESS数据库向MySQL快速迁移小程序(二)_MySQL
程序员文章站
2022-05-13 10:05:52
...
Access
$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 echo "n |
" . odbc_field_name($recordsid,$i) ; $theno = 1 ; echo " |
上一篇: Java 实例 - 获取线程id
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论