PHP code example of mathsgod / light-db

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

    

mathsgod / light-db example snippets


use Light\Db\Model;

class User extends Model {}

$user = User::Create([
    'name' => 'Raymond',
    'email' => '[email protected]'
]);
$user->save();

$user = User::Get(1);
$users = User::Query(['status' => 'active'])->toArray();

$user = User::Get(1);
$user->name = 'New Name';
$user->save();

$user = User::Get(1);
$user->delete();

$user = User::Get(1);
$user->profile['nickname'] = 'Ray';
$user->save();

$user = User::Get(1);
$userLists = $user->UserList; // Get related UserList query object