We are going to write a PHP script that will generate the sample data in a collection named sample_articles
. We will execute the script in the command line and query the collection in mongo
shell to verify the generated data:
1. Fire up your text editor and create a PHP script named
generate_data.php
with the following code in it:<?php require('dbconnection.php'); $titles = array( 'Nature always sides with the hidden flaw', 'Adding manpower to a late software project makes it later.', 'Research supports a specific theory depending on the amount of funds dedicated to it.', 'Always draw your curves, then plot your reading.', 'Software bugs are hard to detect by anybody except may be the end user.',); $authors = array('Luke Skywalker', 'Leia Organa', 'Han Solo', 'Darth Vader', 'Spock', 'James Kirk', 'Hikaru Sulu', 'Nyota Uhura'); $description = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et...