Solved

Inserting data from sql query into Mysql table using PDO

Posted on 2014-02-12
1
606 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
database connection error mysql stops 7 82
if statement malfunction 5 44
Google Recaptcha 13 52
Testing a list of Emails for validity 4 34
This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 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…

739 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