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

35
src/Query/Find.php Normal file
View File

@@ -0,0 +1,35 @@
<?php declare(strict_types=1);
namespace BitBadger\PDODocument\Query;
use BitBadger\PDODocument\{Field, Query};
/**
* Queries for retrieving documents
*/
class Find
{
/**
* Query to retrieve a document by its ID
*
* @param string $tableName The name of the table from which a document should be retrieved
* @return string The SELECT statement to retrieve a document by its ID
*/
public static function byId(string $tableName): string
{
return Query::selectFromTable($tableName) . ' WHERE ' . Query::whereById();
}
/**
* Query to retrieve documents using a comparison on JSON fields
*
* @param string $tableName The name of the table from which documents should be retrieved
* @param Field[] $fields The field comparison to match
* @param string $conjunction How to handle multiple conditions (optional; defaults to `AND`)
* @return string The SELECT statement to retrieve documents by field comparison
*/
public static function byFields(string $tableName, array $fields, string $conjunction = 'AND'): string
{
return Query::selectFromTable($tableName) . ' WHERE ' . Query::whereByFields($fields, $conjunction);
}
}