PHP code example of keenlysoft / database

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

    

keenlysoft / database example snippets




namespace models;

class User extends \database\models
{
    public $table = 'users';
}

$user = User::find('*')->where(['id' => 1])->one();
$users = User::find(['id', 'name'])->pwhere(['status' => 'active'])->all();

$user = new User();
$user->name = 'Ada';
$user->save();

$user->Update(['name' => 'Grace'], ['id' => 1]);
$user->Delete(['id' => 1]);

$user = new User();
$user->begin();

try {
    // Perform database operations.
    $user->commit();
} catch (\Throwable $exception) {
    $user->back();
    throw $exception;
}