1. Go to this page and download the library: Download getgrav/grav-db-kit 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/ */
getgrav / grav-db-kit example snippets
use TrilbyMedia\GravDbKit\Database\ConnectionFactory;
use TrilbyMedia\GravDbKit\Database\KitOptions;
$db = ConnectionFactory::sqlite('/path/to/user/data/helpdesk-pro/db/helpdesk.sqlite', new KitOptions(savepointPrefix: 'hd_sp_'));
// or from a plugin config array: ['type' => 'sqlite'|'mysql'|'pgsql', 'sqlite' => ['path' => …], 'mysql' => […], 'pgsql' => […]]
$db = ConnectionFactory::create($config['database'], $options);
use TrilbyMedia\GravDbKit\Database\Connection;
use TrilbyMedia\GravDbKit\Database\Dialect\Dialect;
use TrilbyMedia\GravDbKit\Database\KitTables;
use TrilbyMedia\GravDbKit\Database\Migration;
use TrilbyMedia\GravDbKit\Schema\InfraTables;
return new class implements Migration {
public function name(): string
{
return '0001_infra';
}
public function steps(Dialect $d): array
{
$t = KitTables::withPrefix('helpdesk');
return [
'create_helpdesk_kv' => InfraTables::kv($d, $t),
'create_helpdesk_jobs' => InfraTables::jobs($d, $t),
'create_helpdesk_rate_limits' => InfraTables::rateLimits($d, $t),
'create_helpdesk_people' => function (Connection $c) use ($d): void {
if (!$d->tableExists($c->pdo(), 'helpdesk_people')) {
$c->run("CREATE TABLE helpdesk_people (id {$d->primaryKey()}, …) {$d->tableOptions()}");
}
},
];
}
};