PHP code example of phith0n / ctfdbbuilder

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

    

phith0n / ctfdbbuilder example snippets



nect = new \CTFDBBuilder\Connection('mysql', [
    'driver'    => 'mysql', // Db driver
    'host'      => 'localhost',
    'database'  => 'your-database',
    'username'  => 'root',
    'password'  => 'your-password',
    'charset'   => 'utf8mb4', // Optional
    'options'   => [ // PDO constructor options, optional
        \PDO::ATTR_TIMEOUT => 5,
        \PDO::ATTR_EMULATE_PREPARES => false,
    ],
]);
$builder = $connect->getBuilder();


$article = $builder->table('articles')->where('id', '=', $_GET['id'])->first();


$article = $builder->table('users')->where('age', '>', $_GET['age'])->first();


$article = $builder->table('users')->orderBy('age', 'desc')->get();


$article = $builder->table('users')->select('COUNT() AS `cnt`')->first();


$article = $builder->table('users')->where('username', $_POST['username'])->where('password', md5($_POST['password']))->first();