Solved

Inserting data from sql query into Mysql table using PDO

Posted on 2014-02-12
1
602 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 110

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

Independent Software Vendors: 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

This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

756 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