<?php set_time_limit(0);
define( 'CONNECTSTRING' , "sqlite:" .dirname( __FILE__ ). "/sqlite3_db_name.db" );
define( 'USERNAME' , 'username' );
define( 'PASSWORD' , 'password' );
define( 'CHARSET' , 'SET NAMES utf8' );
$db = 'localhost' ;
$user = 'usernmae' ;
$pass = 'password' ;
$dbname = 'mysql_db_name' ;
$dbh =null;
if ( $dbh = new PDO(CONNECTSTRING, USERNAME, PASSWORD, array (PDO::MYSQL_ATTR_INIT_COMMAND => CHARSET))){
$dbh ->beginTransaction();
ini_set ( 'memory_limit' , '-1' );
$sth = $dbh ->prepare( 'SELECT * FROM sqlite3_table_name' );
$sth ->execute();
$result = $sth ->fetchAll();
$conn =mysql_connect( $db , $user , $pass ) or die ( "conn error" );
mysql_query( "set names 'utf8'" );
mysql_select_db( $dbname );
foreach ( $result as $row ){
$sql = "" ;
$sql = "INSERT INTO mysql_db_name(colname1,colname2,colname3) VALUES('" ;
$sql = $sql . $row [ 'colname1' ]. "','" . $row [ 'colname2' ]. "','" . $row [ 'colname3' ]. "')" ;
mysql_query( $sql );
}
mysql_close( $conn );
$dbh =null;
}
?>
|