PHP code example of codedgr / database

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

    

codedgr / database example snippets


$values = [
    'firstName' => 'John',
    'lastName' => 'Doe',
];

$id = $db->insert('clients', $values);

$values = [
    'firstName' => 'John',
    'lastName' => 'Doe',
];

$id = $db->insert('clients', $values, true);

$values = [
    'firstName' => 'John',
    'lastName' => 'Doe',
];

$update = [
    'lastName' => 'Doe',
];

$id = $db->insert('clients', $values, $update);

$values = [
    'firstName' => 'John',
    'lastName' => 'Doe',
];
$where = [
    'id' => 2
];

$rowsAffected = $db->update('clients', $values, $where);

$array = $db->select('clients', ['firstName' => 'John' ]);
$array = $db->select('clients', 'firstName = "John"']);

$array = $db->select('clients', 2);

$array = $db->select('clients', ['firstName' => ['like', 'Jo%']]);

$array = $db->select('clients', ['id' => ['>=', 2]]);

$array = $db->select('clients', ['id' => ['in', [1,2,3]]]);

$array = $db->select('clients', ['order' => 'name desc']]);
$array = $db->select('clients', ['order' => 'name desc, id asc']]);

$array = $db->select('clients', ['limit' => 1]]);
$array = $db->select('clients', ['limit' => '1, 5']]);