Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/phith0n/ctfdbbuilder

a database query builder for CTFer(出题专用/开发阶段/慎用)
https://github.com/phith0n/ctfdbbuilder

Last synced: 2 months ago
JSON representation

a database query builder for CTFer(出题专用/开发阶段/慎用)

Awesome Lists containing this project

README

        

# DB Builder for CTFer

一个无任何防护的PHP数据库Builder,支持Mysql/Postgresql/Sqlite。

## Install

```
composer require phith0n/ctfdbbuilder:dev-master
```

## Usage

```php
'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();
```

### Select (SQL injection)

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

```php
table('users')->where('age', '>', $_GET['age'])->first();
```

```php
table('users')->orderBy('age', 'desc')->get();
```

```php
table('users')->select('COUNT() AS `cnt`')->first();
```

```php
table('users')->where('username', $_POST['username'])->where('password', md5($_POST['password']))->first();
```