Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php $m = new Mongo("mongodb://localhost/mongo");
- $host = 'localhost';
- $dbname = 'mongo';
- $user = 'root';
- $password = '';
- $mysqli = new mysqli($host, $user, $password, $dbname);
- if ($mysqli->connect_errno){
- echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
- exit;
- }
- $limit = 10000;
- $offset = 0;
- while(true){
- $res = $mysqli->query("SELECT * FROM basic ORDER BY id ASC LIMIT $offset, $limit");
- if($res->num_rows > 0){
- echo "Result set order... $offset, $limit \n";
- while ($row = $res->fetch_assoc()) {
- $o = new stdClass();
- $o->_id = $row['id'];
- $o->text = $row['text'];
- echo " id = " . $row['id'] . " . text = ".$row['text'].PHP_EOL;
- $m->mongo->basic->insert($o);
- }
- $offset += $limit;
- }else{
- echo 'Done'.PHP_EOL;
- die;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment