- Merging..
This commit is contained in:
commit
6c6733b503
20 files changed
+127
-61
No files matched your search
@@ -15,20 +15,7 @@ interface AdapterInterface {
|
||||
public function connect() : object /* | PdoObject|mixed */;
|
||||
public function buildDataSourceName() : string;
|
||||
public function setup(array $configuration) : void;
|
||||
public function escapeIdentifier(string $segment, int $type) : string;
|
||||
public function defaultEngine() : ? string;
|
||||
|
||||
public function writableValue(/* mixed */ $value); /*: mixed*/
|
||||
|
||||
|
||||
/* public function databaseName() : string;
|
||||
public function mapFieldType(FieldDefinition $field) : string;
|
||||
public function schemaTable(string $databaseName, string $tableName) /*: object|EntityCollection
|
||||
*/
|
||||
public function repositoryClass() : string;
|
||||
public function queryBuilderClass() : string;
|
||||
public function tableSyntax() : array;
|
||||
public function whitelistAttributes(array &$parameters) : void;
|
||||
public function generateAlterColumn(FieldDefinition $definition, array $field) : string|\Stringable;
|
||||
public function splitAlterQuery() : bool;
|
||||
}
|
||||
@@ -9,10 +9,10 @@ use Ulmus\Exception\AdapterConfigurationException;
|
||||
use Ulmus\Ulmus;
|
||||
|
||||
use Ulmus\Migration\FieldDefinition;
|
||||
use Ulmus\{Entity\InformationSchema\Table, Repository, QueryBuilder};
|
||||
use Ulmus\{Entity\InformationSchema\Table, Migration\MigrateInterface, Repository, QueryBuilder};
|
||||
|
||||
class MsSQL implements AdapterInterface {
|
||||
use DefaultAdapterTrait;
|
||||
class MsSQL implements AdapterInterface, MigrateInterface, SqlAdapterInterface {
|
||||
use SqlAdapterTrait;
|
||||
|
||||
const ALLOWED_ATTRIBUTES = [
|
||||
'default', 'primary_key', 'auto_increment',
|
||||
@@ -84,7 +84,7 @@ class MsSQL implements AdapterInterface {
|
||||
$pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
|
||||
$pdo->setAttribute(\PDO::SQLSRV_ATTR_ENCODING, \PDO::SQLSRV_ENCODING_UTF8);
|
||||
}
|
||||
catch(PDOException $ex){
|
||||
catch(\PDOException $ex){
|
||||
throw $ex;
|
||||
}
|
||||
finally {
|
||||
|
||||
+10
-9
@@ -3,6 +3,7 @@
|
||||
namespace Ulmus\Adapter;
|
||||
|
||||
use Ulmus\Entity\InformationSchema\Table;
|
||||
use Ulmus\Migration\MigrateInterface;
|
||||
use Ulmus\QueryBuilder;
|
||||
use Ulmus\Repository;
|
||||
use Ulmus\Common\PdoObject;
|
||||
@@ -11,8 +12,8 @@ use Ulmus\Exception\AdapterConfigurationException;
|
||||
use Ulmus\Ulmus;
|
||||
use Ulmus\Migration\FieldDefinition;
|
||||
|
||||
class MySQL implements AdapterInterface {
|
||||
use DefaultAdapterTrait;
|
||||
class MySQL implements AdapterInterface, MigrateInterface, SqlAdapterInterface {
|
||||
use SqlAdapterTrait;
|
||||
|
||||
const ALLOWED_ATTRIBUTES = [
|
||||
'default', 'primary_key', 'auto_increment', 'update',
|
||||
@@ -21,13 +22,13 @@ class MySQL implements AdapterInterface {
|
||||
const DSN_PREFIX = "mysql";
|
||||
|
||||
public string $hostname;
|
||||
|
||||
|
||||
public string $database;
|
||||
|
||||
public string $username;
|
||||
|
||||
public string $password;
|
||||
|
||||
|
||||
protected string $username;
|
||||
|
||||
protected string $password;
|
||||
|
||||
public string $charset = "utf8mb4";
|
||||
|
||||
public ? string $socket;
|
||||
@@ -77,7 +78,7 @@ class MySQL implements AdapterInterface {
|
||||
$pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
|
||||
$pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
|
||||
}
|
||||
catch(PDOException $ex){
|
||||
catch(\PDOException $ex){
|
||||
throw $ex;
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -8,10 +8,10 @@ use Ulmus\ConnectionAdapter;
|
||||
use Ulmus\Entity\Sqlite\Table;
|
||||
use Ulmus\Exception\AdapterConfigurationException;
|
||||
use Ulmus\Migration\FieldDefinition;
|
||||
use Ulmus\{Repository, QueryBuilder, Ulmus};
|
||||
use Ulmus\{Migration\MigrateInterface, Repository, QueryBuilder, Ulmus};
|
||||
|
||||
class SQLite implements AdapterInterface {
|
||||
use DefaultAdapterTrait;
|
||||
class SQLite implements AdapterInterface, MigrateInterface, SqlAdapterInterface {
|
||||
use SqlAdapterTrait;
|
||||
|
||||
const ALLOWED_ATTRIBUTES = [
|
||||
'default', 'primary_key', 'auto_increment'
|
||||
@@ -40,7 +40,7 @@ class SQLite implements AdapterInterface {
|
||||
$this->exportFunctions($pdo);
|
||||
$this->registerPragma($pdo, $this->pragmaBegin);
|
||||
}
|
||||
catch(PDOException $ex){
|
||||
catch(\PDOException $ex){
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ class SQLite implements AdapterInterface {
|
||||
public function escapeIdentifier(string $segment, int $type) : string
|
||||
{
|
||||
switch($type) {
|
||||
default:
|
||||
case static::IDENTIFIER_DATABASE:
|
||||
case static::IDENTIFIER_TABLE:
|
||||
case static::IDENTIFIER_FIELD:
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Adapter;
|
||||
|
||||
interface SqlAdapterInterface
|
||||
{
|
||||
public function escapeIdentifier(string $segment, int $type) : string;
|
||||
public function defaultEngine() : ? string;
|
||||
}
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
namespace Ulmus\Adapter;
|
||||
|
||||
use Ulmus\{ConnectionAdapter,
|
||||
use Ulmus\{Common\Sql,
|
||||
ConnectionAdapter,
|
||||
Entity\InformationSchema\Table,
|
||||
Migration\FieldDefinition,
|
||||
Repository,
|
||||
QueryBuilder,
|
||||
Ulmus};
|
||||
|
||||
trait DefaultAdapterTrait
|
||||
trait SqlAdapterTrait
|
||||
{
|
||||
public function repositoryClass() : string
|
||||
{
|
||||
@@ -133,7 +134,7 @@ trait DefaultAdapterTrait
|
||||
case is_object($value):
|
||||
return Ulmus::convertObject($value);
|
||||
|
||||
case is_array($value):
|
||||
case is_array($value):
|
||||
return json_encode($value);
|
||||
|
||||
case is_bool($value):
|
||||
Reference in new issue
Block a user