PHP code example of diegogonda / medoo

1. Go to this page and download the library: Download diegogonda/medoo 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/ */

    

diegogonda / medoo example snippets


// If you installed via composer, just use this code to e
use Medoo\Medoo;

// Initialize
$database = new Medoo([
    'database_type' => 'mysql',
    'database_name' => 'name',
    'server' => 'localhost',
    'username' => 'your_username',
    'password' => 'your_password'
]);

// Enjoy
$database->insert('account', [
    'user_name' => 'foo',
    'email' => '[email protected]'
]);

$data = $database->select('account', [
    'user_name',
    'email'
], [
    'user_id' => 50
]);

echo json_encode($data);

// [
//     {
//         "user_name" : "foo",
//         "email" : "[email protected]",
//     }
// ]


use Monolog\{
    Logger,
    Handler\StreamHandler,
};

$medoo = new Medoo([
    'database_type' => 'mysql',
    'database_name' => 'database',
    'server' => 'localhost',
    'username' => '',
    'password' => '',
    'prefix' => 'prefix_',
]);

$logger = new Logger('medoo');
$handler = new StreamHandler("querys.log", Logger::DEBUG);
$logger->pushHandler($handler);

$medoo->setLogger($logger);