Update namespaces #1
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,3 +4,6 @@
|
|||||||
|
|
||||||
# PHPStorm
|
# PHPStorm
|
||||||
**/.idea/
|
**/.idea/
|
||||||
|
|
||||||
|
# PHPUnit
|
||||||
|
**/.phpunit.cache/
|
||||||
|
@ -28,16 +28,16 @@
|
|||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
```
|
```
|
||||||
$container->set(ProVM\Concept\Database\Query\Select::class, function(Psr\Container\ContainerInterface $container) {
|
$container->set(Database\Define\Query\Select::class, function(Psr\Container\ContainerInterface $container) {
|
||||||
return $container->get(ProVM\Database\Query\MySQL\Select::class);
|
return $container->get(ProVM\Database\Query\MySQL\Select::class);
|
||||||
});
|
});
|
||||||
$container->set(ProVM\Concept\Database\Query\Insert::class, function(Psr\Container\ContainerInterface $container) {
|
$container->set(Database\Define\Query\Insert::class, function(Psr\Container\ContainerInterface $container) {
|
||||||
return $container->get(ProVM\Database\Query\MySQL\Insert::class);
|
return $container->get(ProVM\Database\Query\MySQL\Insert::class);
|
||||||
});
|
});
|
||||||
$container->set(ProVM\Concept\Database\Query\Update::class, function(Psr\Container\ContainerInterface $container) {
|
$container->set(Database\Define\Query\Update::class, function(Psr\Container\ContainerInterface $container) {
|
||||||
return $container->get(ProVM\Database\Query\MySQL\Update::class);
|
return $container->get(ProVM\Database\Query\MySQL\Update::class);
|
||||||
});
|
});
|
||||||
$container->set(ProVM\Concept\Database\Query\Delete::class, function(Psr\Container\ContainerInterface $container) {
|
$container->set(Database\Define\Query\Delete::class, function(Psr\Container\ContainerInterface $container) {
|
||||||
return $container->get(ProVM\Database\Query\MySQL\Delete::class);
|
return $container->get(ProVM\Database\Query\MySQL\Delete::class);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"ProVM\\": "src/"
|
"Database\\": "src/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
phpunit.xml
Normal file
25
phpunit.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
|
||||||
|
bootstrap="vendor/autoload.php"
|
||||||
|
cacheDirectory=".phpunit.cache"
|
||||||
|
executionOrder="depends,defects"
|
||||||
|
requireCoverageMetadata="false"
|
||||||
|
beStrictAboutCoverageMetadata="false"
|
||||||
|
beStrictAboutOutputDuringTests="true"
|
||||||
|
displayDetailsOnPhpunitDeprecations="true"
|
||||||
|
failOnPhpunitDeprecation="true"
|
||||||
|
failOnRisky="true"
|
||||||
|
failOnWarning="true">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="default">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
|
||||||
|
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
|
||||||
|
<include>
|
||||||
|
<directory>src</directory>
|
||||||
|
</include>
|
||||||
|
</source>
|
||||||
|
</phpunit>
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
use ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
interface Delete extends Query
|
|
||||||
{
|
|
||||||
public function from(string $table): Delete;
|
|
||||||
public function where(array|string $conditions): Delete;
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
use ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
interface Drop extends Query
|
|
||||||
{
|
|
||||||
public function table(string $table): Drop;
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
use ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
interface Insert extends Query
|
|
||||||
{
|
|
||||||
public function into(string $table): Insert;
|
|
||||||
public function columns(array|string $columns): Insert;
|
|
||||||
public function values(array|string $values): Insert;
|
|
||||||
public function select(Select|string $select): Insert;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
use ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
interface Select extends Query
|
|
||||||
{
|
|
||||||
public function columns(array|string $columns = '*'): Select;
|
|
||||||
public function from(string $table): Select;
|
|
||||||
public function joined(array|string $joins): Select;
|
|
||||||
public function where(array|string $conditions): Select;
|
|
||||||
public function groupBy(array|string $grouping): Select;
|
|
||||||
public function having(array|string $having): Select;
|
|
||||||
public function orderBy(array|string $ordering): Select;
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
use ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
interface Truncate extends Query
|
|
||||||
{
|
|
||||||
public function table(string $table): Truncate;
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
use ProVM\Concept\Database\Query;
|
|
||||||
|
|
||||||
interface Update extends Query
|
|
||||||
{
|
|
||||||
public function table(string $table): Update;
|
|
||||||
public function set(array|string $value_pairs): Update;
|
|
||||||
public function where(array|string $conditions): Update;
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Concept\Database;
|
namespace Database\Define;
|
||||||
|
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Concept\Database\Query;
|
namespace Database\Define\Query;
|
||||||
|
|
||||||
interface Builder
|
interface Builder
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Concept\Database\Query;
|
namespace Database\Define\Query;
|
||||||
|
|
||||||
use ProVM\Concept\Database\Query;
|
use Database\Define\Query;
|
||||||
|
|
||||||
interface Create extends Query
|
interface Create extends Query
|
||||||
{
|
{
|
10
src/Define/Query/Delete.php
Normal file
10
src/Define/Query/Delete.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Define\Query;
|
||||||
|
|
||||||
|
use Database\Define\Query;
|
||||||
|
|
||||||
|
interface Delete extends Query
|
||||||
|
{
|
||||||
|
public function from(string $table): self;
|
||||||
|
public function where(array|string $conditions): self;
|
||||||
|
}
|
9
src/Define/Query/Drop.php
Normal file
9
src/Define/Query/Drop.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Define\Query;
|
||||||
|
|
||||||
|
use Database\Define\Query;
|
||||||
|
|
||||||
|
interface Drop extends Query
|
||||||
|
{
|
||||||
|
public function table(string $table): self;
|
||||||
|
}
|
12
src/Define/Query/Insert.php
Normal file
12
src/Define/Query/Insert.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Define\Query;
|
||||||
|
|
||||||
|
use Database\Define\Query;
|
||||||
|
|
||||||
|
interface Insert extends Query
|
||||||
|
{
|
||||||
|
public function into(string $table): self;
|
||||||
|
public function columns(array|string $columns): self;
|
||||||
|
public function values(array|string $values): self;
|
||||||
|
public function select(Select|string $select): self;
|
||||||
|
}
|
15
src/Define/Query/Select.php
Normal file
15
src/Define/Query/Select.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Define\Query;
|
||||||
|
|
||||||
|
use Database\Define\Query;
|
||||||
|
|
||||||
|
interface Select extends Query
|
||||||
|
{
|
||||||
|
public function columns(array|string $columns = '*'): self;
|
||||||
|
public function from(string $table): self;
|
||||||
|
public function joined(array|string $joins): self;
|
||||||
|
public function where(array|string $conditions): self;
|
||||||
|
public function groupBy(array|string $grouping): self;
|
||||||
|
public function having(array|string $having): self;
|
||||||
|
public function orderBy(array|string $ordering): self;
|
||||||
|
}
|
9
src/Define/Query/Truncate.php
Normal file
9
src/Define/Query/Truncate.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Define\Query;
|
||||||
|
|
||||||
|
use Database\Define\Query;
|
||||||
|
|
||||||
|
interface Truncate extends Query
|
||||||
|
{
|
||||||
|
public function table(string $table): self;
|
||||||
|
}
|
11
src/Define/Query/Update.php
Normal file
11
src/Define/Query/Update.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Define\Query;
|
||||||
|
|
||||||
|
use Database\Define\Query;
|
||||||
|
|
||||||
|
interface Update extends Query
|
||||||
|
{
|
||||||
|
public function table(string $table): self;
|
||||||
|
public function set(array|string $value_pairs): self;
|
||||||
|
public function where(array|string $conditions): self;
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\MySQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Create extends Query\Create
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\MySQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Delete extends Query\Delete
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\MySQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Drop extends Query\Drop
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\MySQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Insert extends Query\Insert
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\MySQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Truncate extends Query\Truncate
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\MySQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Update extends Query\Update
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\PostgreSQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Create extends Query\Create
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\PostgreSQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Delete extends Query\Delete
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\PostgreSQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Drop extends Query\Drop
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\PostgreSQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Insert extends Query\Insert
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\PostgreSQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Select extends Query\Select
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\PostgreSQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Truncate extends Query\Truncate
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Enforce\Database\Query\PostgreSQL;
|
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
|
||||||
|
|
||||||
class Update extends Query\Update
|
|
||||||
{
|
|
||||||
}
|
|
15
src/Except/Missing/Columns.php
Normal file
15
src/Except/Missing/Columns.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Except\Missing;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
use Database\Except;
|
||||||
|
|
||||||
|
class Columns extends Except\Query
|
||||||
|
{
|
||||||
|
public function __construct(string $tableName, ?Throwable $previous = null)
|
||||||
|
{
|
||||||
|
$message = "Missing columns for {$tableName}";
|
||||||
|
$code = 1;
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
15
src/Except/Query.php
Normal file
15
src/Except/Query.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Except;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
abstract class Query extends Exception
|
||||||
|
{
|
||||||
|
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
|
||||||
|
{
|
||||||
|
$message = "Query Exception: {$message}";
|
||||||
|
$code = 1100 + $code;
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Ideal\Database;
|
namespace Database\Ideal;
|
||||||
|
|
||||||
use ProVM\Concept\Database;
|
use Database\Define;
|
||||||
|
|
||||||
abstract class Query implements Database\Query
|
abstract class Query implements Define\Query
|
||||||
{
|
{
|
||||||
public function getType(): string
|
public function getType(): string
|
||||||
{
|
{
|
@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Ideal\Database\Query;
|
namespace Database\Ideal\Query;
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
use Database\Ideal\Query;
|
||||||
use ProVM\Concept\Database;
|
use Database\Define;
|
||||||
use ProVM\Reinforce\Database\Query\hasTable;
|
use Database\Reinforce\Query\hasTable;
|
||||||
|
use Database\Except;
|
||||||
|
|
||||||
abstract class Create extends Query implements Database\Query\Create
|
abstract class Create extends Query implements Define\Query\Create
|
||||||
{
|
{
|
||||||
use hasTable;
|
use hasTable;
|
||||||
|
|
||||||
@ -16,25 +17,25 @@ abstract class Create extends Query implements Database\Query\Create
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isTemp(): Database\Query\Create
|
public function isTemp(): self
|
||||||
{
|
{
|
||||||
$this->temp = true;
|
$this->temp = true;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function ifNotExists(): Database\Query\Create
|
public function ifNotExists(): self
|
||||||
{
|
{
|
||||||
$this->exists = true;
|
$this->exists = true;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function table(string $table): Database\Query\Create
|
public function table(string $table): self
|
||||||
{
|
{
|
||||||
return $this->setTable($table);
|
return $this->setTable($table);
|
||||||
}
|
}
|
||||||
public function columns(array|string $columns): Database\Query\Create
|
public function columns(array|string $columns): self
|
||||||
{
|
{
|
||||||
return $this->setColumns($columns);
|
return $this->setColumns($columns);
|
||||||
}
|
}
|
||||||
public function foreign(array|string $columnDefinition): Database\Query\Create
|
public function foreign(array|string $columnDefinition): self
|
||||||
{
|
{
|
||||||
return $this->setForeign($columnDefinition);
|
return $this->setForeign($columnDefinition);
|
||||||
}
|
}
|
||||||
@ -46,16 +47,19 @@ abstract class Create extends Query implements Database\Query\Create
|
|||||||
|
|
||||||
public function getColumns(): array
|
public function getColumns(): array
|
||||||
{
|
{
|
||||||
|
if (!isset($this->columns)) {
|
||||||
|
throw new Except\Missing\Columns($this->getTable());
|
||||||
|
}
|
||||||
return $this->columns;
|
return $this->columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addColumn(string $column): Database\Query\Create
|
public function addColumn(string $column): self
|
||||||
{
|
{
|
||||||
$this->columns []= $column;
|
$this->columns []= $column;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setColumns(array|string $columns): Database\Query\Create
|
public function setColumns(array|string $columns): self
|
||||||
{
|
{
|
||||||
if (is_string($columns)) {
|
if (is_string($columns)) {
|
||||||
$this->addColumn($columns);
|
$this->addColumn($columns);
|
||||||
@ -70,7 +74,7 @@ abstract class Create extends Query implements Database\Query\Create
|
|||||||
{
|
{
|
||||||
return $this->foreign;
|
return $this->foreign;
|
||||||
}
|
}
|
||||||
public function addForeign(string|array $definition): Database\Query\Create
|
public function addForeign(string|array $definition): self
|
||||||
{
|
{
|
||||||
if (is_string($definition)) {
|
if (is_string($definition)) {
|
||||||
$this->foreign []= $definition;
|
$this->foreign []= $definition;
|
||||||
@ -87,7 +91,7 @@ abstract class Create extends Query implements Database\Query\Create
|
|||||||
$this->foreign []= "CONSTRAINT {$fk} FOREIGN KEY ({$columns}) REFERENCES {$definition['table']} ({$ids}) ON DELETE {$delete} ON UPDATE {$update}";
|
$this->foreign []= "CONSTRAINT {$fk} FOREIGN KEY ({$columns}) REFERENCES {$definition['table']} ({$ids}) ON DELETE {$delete} ON UPDATE {$update}";
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function setForeign(array|string $columnDefinition): Database\Query\Create
|
public function setForeign(array|string $columnDefinition): self
|
||||||
{
|
{
|
||||||
if (is_string($columnDefinition)) {
|
if (is_string($columnDefinition)) {
|
||||||
$this->addForeign($columnDefinition);
|
$this->addForeign($columnDefinition);
|
||||||
@ -109,6 +113,9 @@ abstract class Create extends Query implements Database\Query\Create
|
|||||||
}
|
}
|
||||||
protected function getColumnsString(): string
|
protected function getColumnsString(): string
|
||||||
{
|
{
|
||||||
|
if (!isset($this->columns)) {
|
||||||
|
throw new Except\Missing\Columns($this->getTable());
|
||||||
|
}
|
||||||
if (is_string($this->columns)) {
|
if (is_string($this->columns)) {
|
||||||
return $this->columns;
|
return $this->columns;
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Ideal\Database\Query;
|
namespace Database\Ideal\Query;
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
use Database\Ideal\Query;
|
||||||
use ProVM\Concept\Database;
|
use Database\Define;
|
||||||
use ProVM\Reinforce\Database\Query\{hasConditions, hasTable};
|
use Database\Reinforce\Query\{hasConditions, hasTable};
|
||||||
|
|
||||||
abstract class Delete extends Query implements Database\Query\Delete
|
abstract class Delete extends Query implements Define\Query\Delete
|
||||||
{
|
{
|
||||||
use hasTable, hasConditions;
|
use hasTable, hasConditions;
|
||||||
|
|
||||||
@ -15,11 +15,11 @@ abstract class Delete extends Query implements Database\Query\Delete
|
|||||||
$this->from($table);
|
$this->from($table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function from(string $table): Database\Query\Delete
|
public function from(string $table): self
|
||||||
{
|
{
|
||||||
return $this->setTable($table);
|
return $this->setTable($table);
|
||||||
}
|
}
|
||||||
public function where(array|string $conditions): Database\Query\Delete
|
public function where(array|string $conditions): self
|
||||||
{
|
{
|
||||||
return $this->setConditions($conditions);
|
return $this->setConditions($conditions);
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Ideal\Database\Query;
|
namespace Database\Ideal\Query;
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
use Database\Ideal\Query;
|
||||||
use ProVM\Concept\Database;
|
use Database\Define;
|
||||||
use ProVM\Reinforce\Database\Query\hasTable;
|
use Database\Reinforce\Query\hasTable;
|
||||||
|
|
||||||
abstract class Drop extends Query implements Database\Query\Drop
|
abstract class Drop extends Query implements Define\Query\Drop
|
||||||
{
|
{
|
||||||
use hasTable;
|
use hasTable;
|
||||||
|
|
||||||
@ -15,11 +15,11 @@ abstract class Drop extends Query implements Database\Query\Drop
|
|||||||
$this->table($table);
|
$this->table($table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function table(string $table): Database\Query\Drop
|
public function table(string $table): self
|
||||||
{
|
{
|
||||||
return $this->setTable($table);
|
return $this->setTable($table);
|
||||||
}
|
}
|
||||||
public function cascade(): Database\Query\Drop
|
public function cascade(): self
|
||||||
{
|
{
|
||||||
$this->cascade = true;
|
$this->cascade = true;
|
||||||
return $this;
|
return $this;
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Ideal\Database\Query;
|
namespace Database\Ideal\Query;
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
use Database\Ideal\Query;
|
||||||
use ProVM\Concept\Database;
|
use Database\Define;
|
||||||
use ProVM\Reinforce\Database\Query\hasTable;
|
use Database\Reinforce\Query\hasTable;
|
||||||
|
|
||||||
abstract class Insert extends Query implements Database\Query\Insert
|
abstract class Insert extends Query implements Define\Query\Insert
|
||||||
{
|
{
|
||||||
use hasTable;
|
use hasTable;
|
||||||
|
|
||||||
@ -16,26 +16,26 @@ abstract class Insert extends Query implements Database\Query\Insert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function into(string $table): Database\Query\Insert
|
public function into(string $table): self
|
||||||
{
|
{
|
||||||
return $this->setTable($table);
|
return $this->setTable($table);
|
||||||
}
|
}
|
||||||
public function columns(array|string $columns): Database\Query\Insert
|
public function columns(array|string $columns): self
|
||||||
{
|
{
|
||||||
return $this->setColumns($columns);
|
return $this->setColumns($columns);
|
||||||
}
|
}
|
||||||
public function values(array|string $values): Database\Query\Insert
|
public function values(array|string $values): self
|
||||||
{
|
{
|
||||||
return $this->setValues($values);
|
return $this->setValues($values);
|
||||||
}
|
}
|
||||||
public function select(Database\Query\Select|string $select): Database\Query\Insert
|
public function select(Define\Query\Select|string $select): self
|
||||||
{
|
{
|
||||||
return $this->setSelect($select);
|
return $this->setSelect($select);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected array|string $columns;
|
protected array|string $columns;
|
||||||
protected array|string $values;
|
protected array|string $values;
|
||||||
protected Database\Query\Select|string $select;
|
protected Define\Query\Select|string $select;
|
||||||
|
|
||||||
public function getColumns(): array|string
|
public function getColumns(): array|string
|
||||||
{
|
{
|
||||||
@ -45,22 +45,22 @@ abstract class Insert extends Query implements Database\Query\Insert
|
|||||||
{
|
{
|
||||||
return $this->values;
|
return $this->values;
|
||||||
}
|
}
|
||||||
public function getSelect(): Database\Query\Select|string
|
public function getSelect(): Define\Query\Select|string
|
||||||
{
|
{
|
||||||
return $this->select;
|
return $this->select;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setColumns(array|string $columns): Database\Query\Insert
|
public function setColumns(array|string $columns): self
|
||||||
{
|
{
|
||||||
$this->columns = $columns;
|
$this->columns = $columns;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function setValues(array|string $values): Database\Query\Insert
|
public function setValues(array|string $values): self
|
||||||
{
|
{
|
||||||
$this->values = $values;
|
$this->values = $values;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function setSelect(Database\Query\Select|string $select): Database\Query\Insert
|
public function setSelect(Define\Query\Select|string $select): self
|
||||||
{
|
{
|
||||||
$this->select = $select;
|
$this->select = $select;
|
||||||
return $this;
|
return $this;
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Ideal\Database\Query;
|
namespace Database\Ideal\Query;
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
use Database\Ideal\Query;
|
||||||
use ProVM\Concept\Database;
|
use Database\Define;
|
||||||
use ProVM\Reinforce\Database\Query\{hasConditions, hasTable};
|
use Database\Reinforce\Query\{hasConditions, hasTable};
|
||||||
|
|
||||||
abstract class Select extends Query implements Database\Query\Select
|
abstract class Select extends Query implements Define\Query\Select
|
||||||
{
|
{
|
||||||
use hasTable, hasConditions;
|
use hasTable, hasConditions;
|
||||||
|
|
||||||
@ -14,35 +14,35 @@ abstract class Select extends Query implements Database\Query\Select
|
|||||||
$this->columns($columns);
|
$this->columns($columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function columns(array|string $columns = '*'): Database\Query\Select
|
public function columns(array|string $columns = '*'): self
|
||||||
{
|
{
|
||||||
return $this->setColumns($columns);
|
return $this->setColumns($columns);
|
||||||
}
|
}
|
||||||
public function from(string $table): Database\Query\Select
|
public function from(string $table): self
|
||||||
{
|
{
|
||||||
return $this->setTable($table);
|
return $this->setTable($table);
|
||||||
}
|
}
|
||||||
public function joined(array|string $joins): Database\Query\Select
|
public function joined(array|string $joins): self
|
||||||
{
|
{
|
||||||
return $this->setJoins($joins);
|
return $this->setJoins($joins);
|
||||||
}
|
}
|
||||||
public function where(array|string $conditions): Database\Query\Select
|
public function where(array|string $conditions): self
|
||||||
{
|
{
|
||||||
return $this->setConditions($conditions);
|
return $this->setConditions($conditions);
|
||||||
}
|
}
|
||||||
public function groupBy(array|string $grouping): Database\Query\Select
|
public function groupBy(array|string $grouping): self
|
||||||
{
|
{
|
||||||
return $this->setGroups($grouping);
|
return $this->setGroups($grouping);
|
||||||
}
|
}
|
||||||
public function having(array|string $having): Database\Query\Select
|
public function having(array|string $having): self
|
||||||
{
|
{
|
||||||
return $this->setHaving($having);
|
return $this->setHaving($having);
|
||||||
}
|
}
|
||||||
public function orderBy(array|string $ordering): Database\Query\Select
|
public function orderBy(array|string $ordering): self
|
||||||
{
|
{
|
||||||
return $this->setOrders($ordering);
|
return $this->setOrders($ordering);
|
||||||
}
|
}
|
||||||
public function limit(int $limit, ?int $offset = null): Database\Query\Select
|
public function limit(int $limit, ?int $offset = null): self
|
||||||
{
|
{
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
if ($offset !== null) {
|
if ($offset !== null) {
|
||||||
@ -85,7 +85,7 @@ abstract class Select extends Query implements Database\Query\Select
|
|||||||
return $this->orders;
|
return $this->orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addColumn(string $column, ?string $alias = null): Database\Query\Select
|
public function addColumn(string $column, ?string $alias = null): self
|
||||||
{
|
{
|
||||||
if ($column === '*') {
|
if ($column === '*') {
|
||||||
$this->columns []= $column;
|
$this->columns []= $column;
|
||||||
@ -98,22 +98,22 @@ abstract class Select extends Query implements Database\Query\Select
|
|||||||
$this->columns[] = "`{$column}`{$a}";
|
$this->columns[] = "`{$column}`{$a}";
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function addJoin(string $table, string $expression): Database\Query\Select
|
public function addJoin(string $table, string $expression): self
|
||||||
{
|
{
|
||||||
$this->joins []= "{$table} ON {$expression}";
|
$this->joins []= "{$table} ON {$expression}";
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function addGroup(string $group): Database\Query\Select
|
public function addGroup(string $group): self
|
||||||
{
|
{
|
||||||
$this->groups []= "`{$group}`";
|
$this->groups []= "`{$group}`";
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function addHaving(string $having): Database\Query\Select
|
public function addHaving(string $having): self
|
||||||
{
|
{
|
||||||
$this->having []= $having;
|
$this->having []= $having;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function addOrder(string $column, ?string $direction = null): Database\Query\Select
|
public function addOrder(string $column, ?string $direction = null): self
|
||||||
{
|
{
|
||||||
if ($direction === null) {
|
if ($direction === null) {
|
||||||
$direction = 'ASC';
|
$direction = 'ASC';
|
||||||
@ -122,7 +122,7 @@ abstract class Select extends Query implements Database\Query\Select
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setColumns(array|string $columns): Database\Query\Select
|
public function setColumns(array|string $columns): self
|
||||||
{
|
{
|
||||||
if (is_string($columns)) {
|
if (is_string($columns)) {
|
||||||
$this->columns = $columns;
|
$this->columns = $columns;
|
||||||
@ -139,7 +139,7 @@ abstract class Select extends Query implements Database\Query\Select
|
|||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function setJoins(array|string $joins): Database\Query\Select
|
public function setJoins(array|string $joins): self
|
||||||
{
|
{
|
||||||
if (is_string($joins)) {
|
if (is_string($joins)) {
|
||||||
$this->joins = $joins;
|
$this->joins = $joins;
|
||||||
@ -152,7 +152,7 @@ abstract class Select extends Query implements Database\Query\Select
|
|||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function setGroups(array|string $groups): Database\Query\Select
|
public function setGroups(array|string $groups): self
|
||||||
{
|
{
|
||||||
if (is_string($groups)) {
|
if (is_string($groups)) {
|
||||||
$this->groups = $groups;
|
$this->groups = $groups;
|
||||||
@ -163,7 +163,7 @@ abstract class Select extends Query implements Database\Query\Select
|
|||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function setHaving(array|string $having): Database\Query\Select
|
public function setHaving(array|string $having): self
|
||||||
{
|
{
|
||||||
if (is_string($having)) {
|
if (is_string($having)) {
|
||||||
$this->having = $having;
|
$this->having = $having;
|
||||||
@ -174,7 +174,7 @@ abstract class Select extends Query implements Database\Query\Select
|
|||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function setOrders(array|string $orders): Database\Query\Select
|
public function setOrders(array|string $orders): self
|
||||||
{
|
{
|
||||||
if (is_string($orders)) {
|
if (is_string($orders)) {
|
||||||
$this->orders = $orders;
|
$this->orders = $orders;
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Ideal\Database\Query;
|
namespace Database\Ideal\Query;
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
use Database\Ideal\Query;
|
||||||
use ProVM\Concept\Database;
|
use Database\Define;
|
||||||
use ProVM\Reinforce\Database\Query\hasTable;
|
use Database\Reinforce\Query\hasTable;
|
||||||
|
|
||||||
abstract class Truncate extends Query implements Database\Query\Truncate
|
abstract class Truncate extends Query implements Define\Query\Truncate
|
||||||
{
|
{
|
||||||
use hasTable;
|
use hasTable;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ abstract class Truncate extends Query implements Database\Query\Truncate
|
|||||||
$this->table($table);
|
$this->table($table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function table(string $table): Database\Query\Truncate
|
public function table(string $table): self
|
||||||
{
|
{
|
||||||
return $this->setTable($table);
|
return $this->setTable($table);
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Ideal\Database\Query;
|
namespace Database\Ideal\Query;
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
use Database\Ideal\Query;
|
||||||
use ProVM\Concept\Database;
|
use Database\Define;
|
||||||
use ProVM\Reinforce\Database\Query\{hasConditions, hasTable};
|
use Database\Reinforce\Query\{hasConditions, hasTable};
|
||||||
|
|
||||||
abstract class Update extends Query implements Database\Query\Update
|
abstract class Update extends Query implements Define\Query\Update
|
||||||
{
|
{
|
||||||
use hasTable, hasConditions;
|
use hasTable, hasConditions;
|
||||||
|
|
||||||
@ -15,15 +15,15 @@ abstract class Update extends Query implements Database\Query\Update
|
|||||||
$this->table($table);
|
$this->table($table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function table(string $table): Database\Query\Update
|
public function table(string $table): self
|
||||||
{
|
{
|
||||||
return $this->setTable($table);
|
return $this->setTable($table);
|
||||||
}
|
}
|
||||||
public function set(array|string $value_pairs): Database\Query\Update
|
public function set(array|string $value_pairs): self
|
||||||
{
|
{
|
||||||
return $this->setValues($value_pairs);
|
return $this->setValues($value_pairs);
|
||||||
}
|
}
|
||||||
public function where(array|string $conditions): Database\Query\Update
|
public function where(array|string $conditions): self
|
||||||
{
|
{
|
||||||
return $this->setConditions($conditions);
|
return $this->setConditions($conditions);
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ abstract class Update extends Query implements Database\Query\Update
|
|||||||
return $this->values;
|
return $this->values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addValue(string|array $values): Database\Query\Update
|
public function addValue(string|array $values): self
|
||||||
{
|
{
|
||||||
if (is_string($values)) {
|
if (is_string($values)) {
|
||||||
$this->values []= $values;
|
$this->values []= $values;
|
||||||
@ -50,7 +50,7 @@ abstract class Update extends Query implements Database\Query\Update
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setValues(array|string $values): Database\Query\Update
|
public function setValues(array|string $values): self
|
||||||
{
|
{
|
||||||
if (is_string($values)) {
|
if (is_string($values)) {
|
||||||
$this->addValue($values);
|
$this->addValue($values);
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Enforce\Database\Query;
|
namespace Database\Implement\Query;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use FilesystemIterator;
|
use FilesystemIterator;
|
||||||
use ProVM\Concept\Database\Query;
|
use Database\Define\Query;
|
||||||
|
|
||||||
class Builder implements Query\Builder
|
class Builder implements Query\Builder
|
||||||
{
|
{
|
||||||
@ -52,13 +52,13 @@ class Builder implements Query\Builder
|
|||||||
return $this->query_classes[$query_interface];
|
return $this->query_classes[$query_interface];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addQuery(string $query_interface, string $query): Builder
|
protected function addQuery(string $query_interface, string $query): self
|
||||||
{
|
{
|
||||||
$this->query_classes[$query_interface] = $query;
|
$this->query_classes[$query_interface] = $query;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setQueries(array $queries): Builder
|
protected function setQueries(array $queries): self
|
||||||
{
|
{
|
||||||
foreach ($queries as $interface => $query) {
|
foreach ($queries as $interface => $query) {
|
||||||
$this->addQuery($interface, $query);
|
$this->addQuery($interface, $query);
|
13
src/Implement/Query/MySQL/Create.php
Normal file
13
src/Implement/Query/MySQL/Create.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\MySQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Create extends Query\Create
|
||||||
|
{
|
||||||
|
public function getTable(): string
|
||||||
|
{
|
||||||
|
$table = parent::getTable();
|
||||||
|
return "`{$table}`";
|
||||||
|
}
|
||||||
|
}
|
13
src/Implement/Query/MySQL/Delete.php
Normal file
13
src/Implement/Query/MySQL/Delete.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\MySQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Delete extends Query\Delete
|
||||||
|
{
|
||||||
|
public function getTable(): string
|
||||||
|
{
|
||||||
|
$table = parent::getTable();
|
||||||
|
return "`{$table}`";
|
||||||
|
}
|
||||||
|
}
|
13
src/Implement/Query/MySQL/Drop.php
Normal file
13
src/Implement/Query/MySQL/Drop.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\MySQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Drop extends Query\Drop
|
||||||
|
{
|
||||||
|
public function getTable(): string
|
||||||
|
{
|
||||||
|
$table = parent::getTable();
|
||||||
|
return "`{$table}`";
|
||||||
|
}
|
||||||
|
}
|
13
src/Implement/Query/MySQL/Insert.php
Normal file
13
src/Implement/Query/MySQL/Insert.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\MySQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Insert extends Query\Insert
|
||||||
|
{
|
||||||
|
public function getTable(): string
|
||||||
|
{
|
||||||
|
$table = parent::getTable();
|
||||||
|
return "`{$table}`";
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Enforce\Database\Query\MySQL;
|
namespace Database\Implement\Query\MySQL;
|
||||||
|
|
||||||
use ProVM\Ideal\Database\Query;
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
class Select extends Query\Select
|
class Select extends Query\Select
|
||||||
{
|
{
|
||||||
public function limit(int $limit, ?int $offset = null): Select
|
public function limit(int $limit, ?int $offset = null): self
|
||||||
{
|
{
|
||||||
$this->setLimit($limit);
|
$this->setLimit($limit);
|
||||||
if ($offset !== null) {
|
if ($offset !== null) {
|
||||||
@ -14,6 +14,12 @@ class Select extends Query\Select
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTable(): string
|
||||||
|
{
|
||||||
|
$table = parent::getTable();
|
||||||
|
return "`{$table}`";
|
||||||
|
}
|
||||||
|
|
||||||
protected int $limit;
|
protected int $limit;
|
||||||
protected int $offset;
|
protected int $offset;
|
||||||
|
|
||||||
@ -26,12 +32,12 @@ class Select extends Query\Select
|
|||||||
return $this->offset;
|
return $this->offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLimit(int $limit): Select
|
public function setLimit(int $limit): self
|
||||||
{
|
{
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function setOffset(int $offset): Select
|
public function setOffset(int $offset): self
|
||||||
{
|
{
|
||||||
$this->offset = $offset;
|
$this->offset = $offset;
|
||||||
return $this;
|
return $this;
|
13
src/Implement/Query/MySQL/Truncate.php
Normal file
13
src/Implement/Query/MySQL/Truncate.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\MySQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Truncate extends Query\Truncate
|
||||||
|
{
|
||||||
|
public function getTable(): string
|
||||||
|
{
|
||||||
|
$table = parent::getTable();
|
||||||
|
return "`{$table}`";
|
||||||
|
}
|
||||||
|
}
|
22
src/Implement/Query/MySQL/Update.php
Normal file
22
src/Implement/Query/MySQL/Update.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\MySQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Update extends Query\Update
|
||||||
|
{
|
||||||
|
public function getTable(): string
|
||||||
|
{
|
||||||
|
$table = parent::getTable();
|
||||||
|
return "`{$table}`";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function build(): string
|
||||||
|
{
|
||||||
|
return implode('', [
|
||||||
|
"UPDATE TABLE {$this->getTable()}",
|
||||||
|
$this->getValuesString(),
|
||||||
|
$this->getConditionsString()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
8
src/Implement/Query/PostgreSQL/Create.php
Normal file
8
src/Implement/Query/PostgreSQL/Create.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\PostgreSQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Create extends Query\Create
|
||||||
|
{
|
||||||
|
}
|
8
src/Implement/Query/PostgreSQL/Delete.php
Normal file
8
src/Implement/Query/PostgreSQL/Delete.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\PostgreSQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Delete extends Query\Delete
|
||||||
|
{
|
||||||
|
}
|
8
src/Implement/Query/PostgreSQL/Drop.php
Normal file
8
src/Implement/Query/PostgreSQL/Drop.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\PostgreSQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Drop extends Query\Drop
|
||||||
|
{
|
||||||
|
}
|
8
src/Implement/Query/PostgreSQL/Insert.php
Normal file
8
src/Implement/Query/PostgreSQL/Insert.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\PostgreSQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Insert extends Query\Insert
|
||||||
|
{
|
||||||
|
}
|
8
src/Implement/Query/PostgreSQL/Select.php
Normal file
8
src/Implement/Query/PostgreSQL/Select.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\PostgreSQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Select extends Query\Select
|
||||||
|
{
|
||||||
|
}
|
8
src/Implement/Query/PostgreSQL/Truncate.php
Normal file
8
src/Implement/Query/PostgreSQL/Truncate.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\PostgreSQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Truncate extends Query\Truncate
|
||||||
|
{
|
||||||
|
}
|
8
src/Implement/Query/PostgreSQL/Update.php
Normal file
8
src/Implement/Query/PostgreSQL/Update.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Implement\Query\PostgreSQL;
|
||||||
|
|
||||||
|
use Database\Ideal\Query;
|
||||||
|
|
||||||
|
class Update extends Query\Update
|
||||||
|
{
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Reinforce\Database\Query;
|
namespace Database\Reinforce\Query;
|
||||||
|
|
||||||
trait hasConditions
|
trait hasConditions
|
||||||
{
|
{
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProVM\Reinforce\Database\Query;
|
namespace Database\Reinforce\Query;
|
||||||
|
|
||||||
trait hasTable
|
trait hasTable
|
||||||
{
|
{
|
24
tests/MySQLCreateTest.php
Normal file
24
tests/MySQLCreateTest.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class MySQLCreateTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testBaseQuery(): void
|
||||||
|
{
|
||||||
|
$query = new Database\Implement\Query\MySQL\Create();
|
||||||
|
$query->table('test_table');
|
||||||
|
$query->columns('`column1` int');
|
||||||
|
|
||||||
|
$expected = "CREATE TABLE `test_table` (`column1` int)";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, "{$query}");
|
||||||
|
}
|
||||||
|
public function testMissingColumns(): void
|
||||||
|
{
|
||||||
|
$query = new Database\Implement\Query\MySQL\Create();
|
||||||
|
$query->table('test_table');
|
||||||
|
|
||||||
|
$this->expectException(Database\Except\Missing\Columns::class);
|
||||||
|
echo "{$query}";
|
||||||
|
}
|
||||||
|
}
|
15
tests/MySQLDeleteTest.php
Normal file
15
tests/MySQLDeleteTest.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class MySQLDeleteTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testBaseQuery(): void
|
||||||
|
{
|
||||||
|
$query = new Database\Implement\Query\MySQL\Delete();
|
||||||
|
$query->from('test_table');
|
||||||
|
|
||||||
|
$expected = "DELETE FROM `test_table`";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, "{$query}");
|
||||||
|
}
|
||||||
|
}
|
15
tests/MySQLDropTest.php
Normal file
15
tests/MySQLDropTest.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class MySQLDropTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testBaseQuery(): void
|
||||||
|
{
|
||||||
|
$query = new Database\Implement\Query\MySQL\Drop();
|
||||||
|
$query->table('test_table');
|
||||||
|
|
||||||
|
$expected = "DROP TABLE `test_table`";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, "{$query}");
|
||||||
|
}
|
||||||
|
}
|
16
tests/MySQLInsertTest.php
Normal file
16
tests/MySQLInsertTest.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class MySQLInsertTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testBaseQuery(): void
|
||||||
|
{
|
||||||
|
$query = new Database\Implement\Query\MySQL\Insert();
|
||||||
|
$query->into('test_table');
|
||||||
|
$query->values('?, ?, ?');
|
||||||
|
|
||||||
|
$expected = "INSERT INTO `test_table` VALUES (?, ?, ?)";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, "{$query}");
|
||||||
|
}
|
||||||
|
}
|
24
tests/MySQLSelectTest.php
Normal file
24
tests/MySQLSelectTest.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class MySQLSelectTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testBaseQuery(): void
|
||||||
|
{
|
||||||
|
$query = new Database\Implement\Query\MySQL\Select();
|
||||||
|
$query->from('test_table');
|
||||||
|
|
||||||
|
$expected = "SELECT * FROM `test_table`";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, "{$query}");
|
||||||
|
}
|
||||||
|
public function testColumns(): void
|
||||||
|
{
|
||||||
|
$query = new Database\Implement\Query\MySQL\Select('asd');
|
||||||
|
$query->from('test_table');
|
||||||
|
|
||||||
|
$expected = "SELECT asd FROM `test_table`";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, "{$query}");
|
||||||
|
}
|
||||||
|
}
|
15
tests/MySQLTruncateTest.php
Normal file
15
tests/MySQLTruncateTest.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class MySQLTruncateTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testBaseQuery(): void
|
||||||
|
{
|
||||||
|
$query = new Database\Implement\Query\MySQL\Truncate();
|
||||||
|
$query->table('test_table');
|
||||||
|
|
||||||
|
$expected = "TRUNCATE TABLE `test_table`";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, "{$query}");
|
||||||
|
}
|
||||||
|
}
|
16
tests/MySQLUpdateTest.php
Normal file
16
tests/MySQLUpdateTest.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class MySQLUpdateTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testBaseQuery(): void
|
||||||
|
{
|
||||||
|
$query = new Database\Implement\Query\MySQL\Update();
|
||||||
|
$query->table('test_table');
|
||||||
|
$query->set('column1 = 0');
|
||||||
|
|
||||||
|
$expected = "UPDATE TABLE `test_table` SET column1 = 0";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, "{$query}");
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user