PHP Classes

PHP MySQL to Mongo: Import MySQL database into MongoDB

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 624 All time: 5,065 This week: 455Up
Version License PHP version Categories
mysql-to-mongo 1.1GNU Lesser Genera...5.3PHP 5, Databases, Systems administration
Description 

Author

This class can import MySQL database into MongoDB.

It can connect to a given MySQL server to retrieve the records of the tables.

The class can recreate the table records and indexes in a given MongoDB.

Innovation Award
PHP Programming Innovation award winner
August 2014
Winner


Prize: PhpStorm IDE personal permanent license
The possibilities of NoSQL databases motivated many developers to switch from traditional SQL databases like MongoDB.

This class provides an useful solution for those that want to migrate their MySQL databases to MongoDB.

Manuel Lemos
Picture of Orazio Principe
  Performance   Level  
Name: Orazio Principe is available for providing paid consulting. Contact Orazio Principe .
Classes: 8 packages by
Country: Italy Italy
Age: 48
All time rank: 64123 in Italy Italy
Week rank: 164 Up5 in Italy Italy Up
Innovation award
Innovation award
Nominee: 4x

Winner: 2x

Example

<?php

require_once("MySqlToMongo.php");

$mysql_host = "localhost";
$mysql_user = "root";
$mysql_pswd = "";
$mysql_database = "test";

$mongo_host = "localhost";
$mongo_user = "";
$mongo_pswd = "";
$mongo_database = "test";

$imp = new MySqlToMongo();

//Establishing connections to mysql and mongo instances
$imp->mysql_connect($mysql_host, $mysql_user, $mysql_pswd, $mysql_database);
$imp->mongodb_connect($mongo_host, $mongo_user, $mongo_pswd, $mongo_database);

//Set the number of concurrent records to insert
$imp->setBatchRecords(1000);

//Set debug mode to read debug messages
$imp->setDebugMode(true);

//Get all tables from the database
//if you want to import single tables just pass an array of names ex: $list("tbl1","tbl2")
$tables = $imp->getMySqlTables();

//Set the dropping tables if exists into mongo. If false it will append records
$imp->setDropIfExists(true);

//Starting import session
$imp->import($tables);


  Files folder image Files (2)  
File Role Description
Plain text file MySqlToMongo.php Class Main Class
Accessible without login Plain text file MySqlToMongo_test.php Example Example file

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:624
This week:0
All time:5,065
This week:455Up
User Ratings User Comments (1)
 All time
Utility:83%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:-
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:58%StarStarStar
Rank:1511
 
very good class
10 years ago (pooya sabramooz)
70%StarStarStarStar