Hi,
I dont know whether this is the right forum to ask this question.
I would like to copy the table contents from AS/400 DB2 to MySQL table.
For example i have a table in DB2 called JDEdatabase.table1 and would like to copy/transfer the contents to MySQL called MySQLdatabase.table1.
I already created the table1 in MySQL similar to JDEdatabase.table1.
I already installed and connected with MySQL ODBC 3.51 Driver.
How do i need to connect with both the servers and transfer the data from JDEdatabase.table1 to MySQLdatabase.table1 using php?.
I tried the coding, but i am not sure about please help me.
<?php
$dbmysqlhost = "dbhost";
$dbmysqluser = "dbmysqluser";
$dbmysqlpass = "dbmysqlpassr";
//$jdedatabase="jdedatabase";
$jdedbhost="server.jdenetwork";
$jdeuser="jdeuser";
$jdepass="jdepass";
//DB2 database connection get select data from
$jdeconn = odbc_connect($jdedbhost,$jdeuser,$jdepass,"SQL_CUR_USE_ODBC");
$mysqlconn = mysql_connect($dbmysqlhost, $dbmysqluser, $dbmysqlpass ); //database connection to insert data to
$db = mysql_select_db(dbmysqluser, $mysqlconn )
or die ("Couldn't select database from MySQL.");
$getallfieldssql = mysql_query("SELECT * FROM JDEdatabase.table1");
$query = mysql_query($getallfieldssql, $jdeconn);
for ($i=0;$i<($result = mysql_fetch_assoc($query));$i++) {
mysql_query("INSERT INTO table1 ('mysqlfieldname') VALUES ('$jdefieldvalue') ($mysqlconn)");
}
mysql_close($jdeconn);
mysql_close($mysqlconn);
Thanks.