Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Inserting data from sql query into Mysql table using PDO

Posted on 2014-02-12
1
Medium Priority
?
649 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 111

Accepted Solution

by:
Ray Paseur earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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.
Suggested Courses

972 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