35 lines
862 B
PHP
35 lines
862 B
PHP
<?php
|
|
/**
|
|
* Plugin Name: Database Helper
|
|
* Version: 1.0
|
|
* Author: Jan-Niclas Loosen (Loosen-IT and Designraketen GmbH)
|
|
* Author URI: https://example.com
|
|
* License: MIT
|
|
*/
|
|
|
|
use DatabaseHelper\Database;
|
|
use DatabaseHelper\enums\ColumnTypes;
|
|
|
|
try {
|
|
require 'build.php';
|
|
|
|
$table = Database::makeTable('testing-table')
|
|
->primary('col-primary', ColumnTypes::INT, autoInc: true)
|
|
->column('col-one', ColumnTypes::BOOL)
|
|
->column('col-two', ColumnTypes::STRING)
|
|
->create();
|
|
|
|
Database::makeInsertion($table)
|
|
->data('col-one', true)
|
|
->data('col-two', 'A bomb is exploding here!')
|
|
->insert();
|
|
|
|
$results = Database::makeQuery($table)
|
|
->select('col-primary', 'col-one')
|
|
->where('col-one', '=', true)
|
|
->query();
|
|
}
|
|
catch ( Exception $e ) {
|
|
echo $e->getMessage();
|
|
}
|