| 1 |
<?php |
| 2 |
|
| 3 |
namespace CodesVault\Howdyqb; |
| 4 |
|
| 5 |
use CodesVault\Howdyqb\Api\AlterInterface; |
| 6 |
use CodesVault\Howdyqb\Api\CreateInterface; |
| 7 |
use CodesVault\Howdyqb\Api\DeleteInterface; |
| 8 |
use CodesVault\Howdyqb\Api\SelectInterface; |
| 9 |
use CodesVault\Howdyqb\Api\UpdateInterface; |
| 10 |
|
| 11 |
class DB extends QueryFactory |
| 12 |
{ |
| 13 |
public static function select(...$columns): SelectInterface |
| 14 |
{ |
| 15 |
$factory = new self(static::$driver); |
| 16 |
$query = $factory->selectQuery(); |
| 17 |
$query = $query->columns(...$columns); |
| 18 |
return $query; |
| 19 |
} |
| 20 |
|
| 21 |
public static function insert(string $table_name, array $data = []) |
| 22 |
{ |
| 23 |
$factory = new self(static::$driver); |
| 24 |
$query = $factory->insertQuery($table_name, $data); |
| 25 |
return $query; |
| 26 |
} |
| 27 |
|
| 28 |
public static function create(string $table_name): CreateInterface |
| 29 |
{ |
| 30 |
$factory = new self(static::$driver); |
| 31 |
$create = $factory->createQuery($table_name); |
| 32 |
return $create; |
| 33 |
} |
| 34 |
|
| 35 |
public static function alter(string $table_name): AlterInterface |
| 36 |
{ |
| 37 |
$factory = new self(static::$driver); |
| 38 |
$alter = $factory->alterQuery($table_name); |
| 39 |
return $alter; |
| 40 |
} |
| 41 |
|
| 42 |
public static function update(string $table_name, array $data): UpdateInterface |
| 43 |
{ |
| 44 |
$factory = new self(static::$driver); |
| 45 |
$update = $factory->updateQuery($table_name, $data); |
| 46 |
return $update; |
| 47 |
} |
| 48 |
|
| 49 |
public static function delete(string $table_name): DeleteInterface |
| 50 |
{ |
| 51 |
$factory = new self(static::$driver); |
| 52 |
$delete = $factory->deleteQuery($table_name); |
| 53 |
return $delete; |
| 54 |
} |
| 55 |
|
| 56 |
public static function drop(string $table_name) |
| 57 |
{ |
| 58 |
$factory = new self(static::$driver); |
| 59 |
$factory->tableQuery($table_name)->drop(); |
| 60 |
} |
| 61 |
|
| 62 |
public static function dropIfExists(string $table_name) |
| 63 |
{ |
| 64 |
$factory = new self(static::$driver); |
| 65 |
$factory->tableQuery($table_name)->dropIfExists(); |
| 66 |
} |
| 67 |
|
| 68 |
public static function truncate(string $table_name) |
| 69 |
{ |
| 70 |
$factory = new self(static::$driver); |
| 71 |
$factory->tableQuery($table_name)->truncate(); |
| 72 |
} |
| 73 |
} |
| 74 |
|