Initial SQLite development (#1)
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
34
src/Definition.php
Normal file
34
src/Definition.php
Normal 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), []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user