1. Go to this page and download the library: Download mikechip/simplemongo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mikechip / simplemongo example snippets
// Init composer
imple('mongodb://127.0.0.1', 'testdb');
// Create user
$db->insert('users', [
'email' => '[email protected]',
'password' => sha1('123123123'),
'login' => 'admin'
]);
// Update user. No $set is needed
$db->update('users', ['login' => 'admin'], ['password' => sha1('321321321')]);
// Find one user
print_r($db->findOne('users', []));
// Find all users
foreach($db->find('users', []) as $user)
print_r(iterator_to_array($user));
// Count users
print($db->count('users', []));
// Delete user
$db->delete('users', ['login' => 'admin']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.