Advertisement
Guest User

PHP mongo example

a guest
Jul 30th, 2014
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <meta charset="utf-8" />
  4. </head>
  5. <body>
  6.     <pre>
  7.           <?php
  8.  
  9.     $mongo = new MongoClient();
  10.     $db = $mongo->unicorns;
  11.     $col = $db->unicorns;
  12.  
  13.    
  14.     $cur = $col->find(array(
  15.         'weight' => array (
  16.             '$lt' => '400'
  17.             )
  18.         ));
  19.    
  20.     foreach ($cur as $element) {
  21.         echo $element['name'];
  22.     }
  23.  
  24.     print_r($cur);
  25.    
  26.  
  27.     ?>
  28.     </pre>
  29. </body>
  30. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement