Initial SQLite development (#1)

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2024-06-08 23:58:45 +00:00
parent e91acee70f
commit f784f3e52c
66 changed files with 5509 additions and 2 deletions

34
src/Definition.php Normal file
View File

@@ -0,0 +1,34 @@
<?php declare(strict_types=1);
namespace BitBadger\PDODocument;
/**
* Functions to create tables and indexes
*/
class Definition
{
/**
* Ensure a document table exists
*
* @param string $name The name of the table to be created if it does not exist
* @throws DocumentException If any is encountered
*/
public static function ensureTable(string $name): void
{
Custom::nonQuery(Query\Definition::ensureTable($name), []);
Custom::nonQuery(Query\Definition::ensureKey($name), []);
}
/**
* Ensure a field index exists on a document table
*
* @param string $tableName The name of the table which should be indexed
* @param string $indexName The name of the index
* @param array $fields Fields which should be a part of this index
* @throws DocumentException If any is encountered
*/
public static function ensureFieldIndex(string $tableName, string $indexName, array $fields): void
{
Custom::nonQuery(Query\Definition::ensureIndexOn($tableName, $indexName, $fields), []);
}
}