Solved

Inserting data from sql query into Mysql table using PDO

Posted on 2014-02-12
1
575 Views
Last Modified: 2014-06-17
I'm extracting some data from different tables in an oracle database into an array.
I'm trying to insert the fields into a mysql table using PDO connection.

this is the query I make:
$query = "SELECT field1, field2, field3 FROM table1;

$ORACLE_STATIC = OCIParse($ORACLE_CONNECT, $query);
OCIExecute($ORACLE_STATIC, OCI_DEFAULT);

Open in new window


what is the correct way of inserting all the rows from the query using PDO?
I have about 20 fields and 500k rows.
0
Comment
Question by:uilli
1 Comment
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39853737
Details of how to use PDO with MySQL tables are in this article (see the PDO examples associated with each of the steps).
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

The best answer here would depend on how often you intend to do this and what the timeliness requirements might be.  If it's a one-time process, there is not much point in optimizing.  Just run the Oracle query and as your script iterates over the results set, run a single MySQL INSERT query.  You may have to restart the process a few times to get 500K rows moved over, depending on the amount of time that your PHP script is allowed to run.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
php documentation 4 21
Not needed 13 55
wordpress issue 2 20
How to load vendor files from Composer into specify directory 13 17
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now