PHP code example of fight / db

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

    

fight / db example snippets


use src\Db;

Db::init('localhost', '3306', 'novel', 'utf8', 'root', '1');

$list = Db::table('novel_type')
    ->where(['id' => 1])
    ->value('name');
var_dump($list);

$list = Db::table('novel_type')
    ->where(['id' => ['<=', 2]])
    ->column('name');
var_dump($list);

$list = Db::table('novel_type')
    ->field(['id', 'name'])
    ->where(['id' => 1])
    ->find();
var_dump($list);
$list = Db::table('novel_type')
    ->field(['id', 'name'])
    ->where(['id' => ['<=', 2]])
    ->select();
var_dump($list);