- Upgraded "[_Cortex_](https://github.com/ikkez/f3-cortex)" PHP dependency to current dev-master
- Fixed "Deprecation" warning on Composer `1.10.5`, closed #951
This commit is contained in:
76
app/Db/Sql/Mysql/Column.php
Normal file
76
app/Db/Sql/Mysql/Column.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Exodus4D\Pathfinder\Db\Sql\Mysql;
|
||||
|
||||
use DB\SQL;
|
||||
|
||||
class Column extends SQL\Column {
|
||||
|
||||
/**
|
||||
* missing table name error
|
||||
*/
|
||||
const ERROR_TABLE_NAME_MISSING = 'Table name missing for FOREIGN KEY in `%s`';
|
||||
|
||||
/**
|
||||
* drop constraint from this column
|
||||
* @param Constraint $constraint
|
||||
*/
|
||||
public function dropConstraint(Constraint $constraint){
|
||||
$this->table->dropConstraint($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* add constraint to this column
|
||||
* @param Constraint $constraint
|
||||
*/
|
||||
public function addConstraint(Constraint $constraint){
|
||||
$this->table->addConstraint($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Constraint $constraint
|
||||
* @return mixed
|
||||
*/
|
||||
public function constraintExists(Constraint $constraint){
|
||||
return $this->table->constraintExists($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* get a new column based constraint
|
||||
* $constraintData['table'] => referenceTable name (required)
|
||||
* $constraintData['id'] => referenceColumns (optional) default: ['id']
|
||||
* $constraintData['on-delete'] => ON DELETE action (optional) default: see \DB\SQL\MySQL\Constraint const
|
||||
* $constraintData['on-update'] => ON UPDATE action (optional) default: see \DB\SQL\MySQL\Constraint const
|
||||
*
|
||||
* @param array $constraintData
|
||||
* @return Constraint
|
||||
*/
|
||||
public function newConstraint($constraintData){
|
||||
|
||||
$constraint = null;
|
||||
|
||||
if(isset($constraintData['table'])){
|
||||
if(isset($constraintData['column'])){
|
||||
$constraintData['column'] = (array)$constraintData['column'];
|
||||
}else{
|
||||
$constraintData['column'] = ['id'];
|
||||
}
|
||||
|
||||
$constraint = new Constraint($this->table, $this->name, $constraintData['table'], $constraintData['column']);
|
||||
|
||||
if(isset($constraintData['on-delete'])){
|
||||
$constraint->setOnDelete($constraintData['on-delete']);
|
||||
}
|
||||
|
||||
if(isset($constraintData['on-update'])){
|
||||
$constraint->setOnUpdate($constraintData['on-update']);
|
||||
}
|
||||
|
||||
}else{
|
||||
trigger_error(sprintf(self::ERROR_TABLE_NAME_MISSING, $this->table->name . '->' . $this->name));
|
||||
}
|
||||
|
||||
return $constraint;
|
||||
}
|
||||
}
|
||||
162
app/Db/Sql/Mysql/Constraint.php
Normal file
162
app/Db/Sql/Mysql/Constraint.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Exodus4D\Pathfinder\Db\Sql\Mysql;
|
||||
|
||||
|
||||
use DB\SQL;
|
||||
|
||||
class Constraint {
|
||||
|
||||
// available actions
|
||||
const ACTIONS_DELETE = ['RESTRICT', 'CASCADE', 'SET NULL', 'NO ACTION'];
|
||||
const ACTIONS_UPDATE = ['RESTRICT', 'CASCADE', 'SET NULL', 'NO ACTION'];
|
||||
|
||||
// default actions
|
||||
const ACTION_DELETE = 'RESTRICT';
|
||||
const ACTION_UPDATE = 'RESTRICT';
|
||||
|
||||
const ERROR_ACTION_NOT_SUPPORTED = 'Constraint action `%s` is not supported.';
|
||||
|
||||
protected $table;
|
||||
protected $keys = [];
|
||||
protected $referencedTable = '';
|
||||
protected $referencedCols = [];
|
||||
protected $onDelete = self::ACTION_DELETE;
|
||||
protected $onUpdate = self::ACTION_UPDATE;
|
||||
|
||||
/**
|
||||
* Constraint constructor.
|
||||
* @param SQL\TableBuilder $table
|
||||
* @param array $keys
|
||||
* @param string $referencedTable
|
||||
* @param array $referencedCols
|
||||
*/
|
||||
public function __construct(SQL\TableBuilder $table, $keys = [], $referencedTable = '', $referencedCols = ['id']){
|
||||
$this->table = &$table;
|
||||
$this->setKeys($keys);
|
||||
$this->setReferencedTable($referencedTable);
|
||||
$this->setReferencedCols($referencedCols);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $keys
|
||||
*/
|
||||
public function setKeys($keys){
|
||||
$this->keys = (array)$keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $referencedTable
|
||||
*/
|
||||
public function setReferencedTable($referencedTable){
|
||||
$this->referencedTable = $referencedTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $referencedCols
|
||||
*/
|
||||
public function setReferencedCols($referencedCols){
|
||||
$this->referencedCols = (array)$referencedCols;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $onDelete
|
||||
*/
|
||||
public function setOnDelete($onDelete){
|
||||
if( in_array($onDelete, self::ACTIONS_DELETE) ){
|
||||
$this->onDelete = $onDelete;
|
||||
}else{
|
||||
trigger_error(sprintf(self::ERROR_ACTION_NOT_SUPPORTED, $onDelete));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $onUpdate
|
||||
*/
|
||||
public function setOnUpdate($onUpdate){
|
||||
if( in_array($onUpdate, self::ACTIONS_UPDATE) ){
|
||||
$this->onUpdate = $onUpdate;
|
||||
}else{
|
||||
trigger_error(sprintf(self::ERROR_ACTION_NOT_SUPPORTED, $onUpdate));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getKeys(){
|
||||
return $this->keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReferencedTable(){
|
||||
return $this->referencedTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getReferencedCols(){
|
||||
return $this->referencedCols;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOnDelete(){
|
||||
return $this->onDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOnUpdate(){
|
||||
return $this->onUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* get a constraint name for this table.
|
||||
* This can either be used to generate unique constraint names for foreign keys in parent tables
|
||||
* or generate a "part" of a name. e.g. for db-Query all constraints of this table (ignore columns)
|
||||
* by "LIKE" selecting "information_schema"
|
||||
* -> To get a certain constraint or generate a unique constraint, ALL params are required!
|
||||
* @return string
|
||||
*/
|
||||
public function getConstraintName(){
|
||||
$constraintName = 'fk_' . $this->table->name;
|
||||
|
||||
if(!empty($this->getKeys())){
|
||||
$constraintName .= '___' . implode('__', $this->getKeys());
|
||||
if(!empty($this->getReferencedTable())){
|
||||
$constraintName .= '___' . $this->getReferencedTable();
|
||||
if(!empty($this->getReferencedCols())){
|
||||
$constraintName .= '___' . implode('__', $this->getReferencedCols());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $constraintName;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if constraint is valid
|
||||
* -> all required members must be set!
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(){
|
||||
$valid = false;
|
||||
|
||||
if(
|
||||
!empty($this->getKeys()) &&
|
||||
!empty($this->getReferencedTable()) &&
|
||||
!empty($this->getReferencedCols())
|
||||
){
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
}
|
||||
111
app/Db/Sql/Mysql/TableModifier.php
Normal file
111
app/Db/Sql/Mysql/TableModifier.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exodus
|
||||
* Date: 19.12.2015
|
||||
* Time: 12:47
|
||||
*
|
||||
* This is an "on top" extension for "Schema Builder"
|
||||
* see: https://github.com/ikkez/f3-schema-builder
|
||||
*
|
||||
* Features:
|
||||
* - FOREIGN KEY CONSTRAINTS (single column key)
|
||||
*/
|
||||
|
||||
namespace Exodus4D\Pathfinder\Db\Sql\Mysql;
|
||||
|
||||
|
||||
use DB\SQL;
|
||||
|
||||
class TableModifier extends SQL\TableModifier {
|
||||
|
||||
/**
|
||||
* invalid constraint error
|
||||
*/
|
||||
const ERROR_CONSTRAINT_NOT_VALID = 'Constraint `%s` is not valid';
|
||||
|
||||
/**
|
||||
* return table foreign key constraints as assoc array
|
||||
* -> if §constraint is passed, constraints are limited to that column
|
||||
* @param null| Constraint $constraint
|
||||
* @return Constraint[]
|
||||
*/
|
||||
public function listConstraint($constraint = null){
|
||||
|
||||
$constraintName = '%';
|
||||
$keys = [];
|
||||
if($constraint instanceof Constraint){
|
||||
// list constraints for given column in this table
|
||||
$constraintName = $constraint->getConstraintName() . '%';
|
||||
$keys = $constraint->getKeys();
|
||||
}
|
||||
|
||||
$this->db->exec("USE information_schema");
|
||||
$constraintsData = $this->db->exec("
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
referential_constraints
|
||||
WHERE
|
||||
constraint_schema = :db AND
|
||||
table_name = :table AND
|
||||
constraint_name LIKE :constraint_name
|
||||
", [
|
||||
':db' => $this->db->name(),
|
||||
':table' => $this->name,
|
||||
':constraint_name' => $constraintName
|
||||
]);
|
||||
// switch back to current DB
|
||||
$this->db->exec("USE " . $this->db->quotekey($this->db->name()));
|
||||
|
||||
$constraints = [];
|
||||
foreach($constraintsData as $data){
|
||||
$constraints[$data['CONSTRAINT_NAME']] = new Constraint($this, $keys, $data['REFERENCED_TABLE_NAME'] );
|
||||
}
|
||||
|
||||
return $constraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether a constraint name exists or not
|
||||
* -> does not check constraint params
|
||||
* @param Constraint $constraint
|
||||
* @return bool
|
||||
*/
|
||||
public function constraintExists($constraint){
|
||||
$constraints = $this->listConstraint();
|
||||
return array_key_exists($constraint->getConstraintName(), $constraints);
|
||||
}
|
||||
|
||||
/**
|
||||
* drop foreign key constraint
|
||||
* @param Constraint $constraint
|
||||
*/
|
||||
public function dropConstraint($constraint){
|
||||
if($constraint->isValid()){
|
||||
$this->queries[] = "ALTER TABLE " . $this->db->quotekey($this->name) . "
|
||||
DROP FOREIGN KEY " . $this->db->quotekey($constraint->getConstraintName()) . ";";
|
||||
}else{
|
||||
trigger_error(sprintf(self::ERROR_CONSTRAINT_NOT_VALID, 'table: ' . $this->name . ' constraintName: ' . $constraint->getConstraintName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/Update foreign key constraint
|
||||
* @param Constraint $constraint
|
||||
*/
|
||||
public function addConstraint($constraint){
|
||||
|
||||
if($constraint->isValid()){
|
||||
$this->queries[] = "
|
||||
ALTER TABLE " . $this->db->quotekey($this->name) . "
|
||||
ADD CONSTRAINT " . $this->db->quotekey($constraint->getConstraintName()) . "
|
||||
FOREIGN KEY (" . implode(', ', $constraint->getKeys()) . ")
|
||||
REFERENCES " . $this->db->quotekey($constraint->getReferencedTable()) . " (" . implode(', ', $constraint->getReferencedCols()) . ")
|
||||
ON DELETE " . $constraint->getOnDelete() . "
|
||||
ON UPDATE " . $constraint->getOnUpdate() . ";";
|
||||
}else{
|
||||
trigger_error(sprintf(self::ERROR_CONSTRAINT_NOT_VALID, 'table: ' . $this->name . ' constraintName: ' . $constraint->getConstraintName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,337 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exodus
|
||||
* Date: 19.12.2015
|
||||
* Time: 12:47
|
||||
*
|
||||
* This is an "on top" extension for "Schema Builder"
|
||||
* see: https://github.com/ikkez/f3-schema-builder
|
||||
*
|
||||
* Features:
|
||||
* - FOREIGN KEY CONSTRAINTS (single column key)
|
||||
*/
|
||||
|
||||
namespace Exodus4D\Pathfinder\Db\Sql\Mysql;
|
||||
|
||||
|
||||
use DB\SQL;
|
||||
|
||||
class TableModifier extends SQL\TableModifier {
|
||||
|
||||
const TEXT_ConstraintNotValid = 'Constraint `%s` is not valid';
|
||||
|
||||
|
||||
/**
|
||||
* return table foreign key constraints as assoc array
|
||||
* -> if §constraint is passed, constraints are limited to that column
|
||||
* @param null| Constraint $constraint
|
||||
* @return Constraint[]
|
||||
*/
|
||||
public function listConstraint($constraint = null){
|
||||
|
||||
$constraintName = '%';
|
||||
$keys = [];
|
||||
if($constraint instanceof Constraint){
|
||||
// list constraints for given column in this table
|
||||
$constraintName = $constraint->getConstraintName() . '%';
|
||||
$keys = $constraint->getKeys();
|
||||
}
|
||||
|
||||
$this->db->exec("USE information_schema");
|
||||
$constraintsData = $this->db->exec("
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
referential_constraints
|
||||
WHERE
|
||||
constraint_schema = :db AND
|
||||
table_name = :table AND
|
||||
constraint_name LIKE :constraint_name
|
||||
", [
|
||||
':db' => $this->db->name(),
|
||||
':table' => $this->name,
|
||||
':constraint_name' => $constraintName
|
||||
]);
|
||||
// switch back to current DB
|
||||
$this->db->exec("USE " . $this->db->quotekey($this->db->name()));
|
||||
|
||||
$constraints = [];
|
||||
foreach($constraintsData as $data){
|
||||
$constraints[$data['CONSTRAINT_NAME']] = new Constraint($this, $keys, $data['REFERENCED_TABLE_NAME'] );
|
||||
}
|
||||
|
||||
return $constraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether a constraint name exists or not
|
||||
* -> does not check constraint params
|
||||
* @param Constraint $constraint
|
||||
* @return bool
|
||||
*/
|
||||
public function constraintExists($constraint){
|
||||
$constraints = $this->listConstraint();
|
||||
return array_key_exists($constraint->getConstraintName(), $constraints);
|
||||
}
|
||||
|
||||
/**
|
||||
* drop foreign key constraint
|
||||
* @param Constraint $constraint
|
||||
*/
|
||||
public function dropConstraint($constraint){
|
||||
if($constraint->isValid()){
|
||||
$this->queries[] = "ALTER TABLE " . $this->db->quotekey($this->name) . "
|
||||
DROP FOREIGN KEY " . $this->db->quotekey($constraint->getConstraintName()) . ";";
|
||||
}else{
|
||||
trigger_error(sprintf(self::TEXT_ConstraintNotValid, 'table: ' . $this->name . ' constraintName: ' . $constraint->getConstraintName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/Update foreign key constraint
|
||||
* @param Constraint $constraint
|
||||
*/
|
||||
public function addConstraint($constraint){
|
||||
|
||||
if($constraint->isValid()){
|
||||
$this->queries[] = "
|
||||
ALTER TABLE " . $this->db->quotekey($this->name) . "
|
||||
ADD CONSTRAINT " . $this->db->quotekey($constraint->getConstraintName()) . "
|
||||
FOREIGN KEY (" . implode(', ', $constraint->getKeys()) . ")
|
||||
REFERENCES " . $this->db->quotekey($constraint->getReferencedTable()) . " (" . implode(', ', $constraint->getReferencedCols()) . ")
|
||||
ON DELETE " . $constraint->getOnDelete() . "
|
||||
ON UPDATE " . $constraint->getOnUpdate() . ";";
|
||||
}else{
|
||||
trigger_error(sprintf(self::TEXT_ConstraintNotValid, 'table: ' . $this->name . ' constraintName: ' . $constraint->getConstraintName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Column
|
||||
* @package DB\SQL\MySQL
|
||||
*/
|
||||
class Column extends SQL\Column {
|
||||
|
||||
const TEXT_TableNameMissing = 'Table name missing for FOREIGN KEY in `%s`';
|
||||
|
||||
/**
|
||||
* drop constraint from this column
|
||||
* @param Constraint $constraint
|
||||
*/
|
||||
public function dropConstraint(Constraint $constraint){
|
||||
$this->table->dropConstraint($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* add constraint to this column
|
||||
* @param Constraint $constraint
|
||||
*/
|
||||
public function addConstraint(Constraint $constraint){
|
||||
$this->table->addConstraint($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Constraint $constraint
|
||||
* @return mixed
|
||||
*/
|
||||
public function constraintExists(Constraint $constraint){
|
||||
return $this->table->constraintExists($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* get a new column based constraint
|
||||
* $constraintData['table'] => referenceTable name (required)
|
||||
* $constraintData['id'] => referenceColumns (optional) default: ['id']
|
||||
* $constraintData['on-delete'] => ON DELETE action (optional) default: see \DB\SQL\MySQL\Constraint const
|
||||
* $constraintData['on-update'] => ON UPDATE action (optional) default: see \DB\SQL\MySQL\Constraint const
|
||||
*
|
||||
* @param array $constraintData
|
||||
* @return Constraint
|
||||
*/
|
||||
public function newConstraint($constraintData){
|
||||
|
||||
$constraint = null;
|
||||
|
||||
if(isset($constraintData['table'])){
|
||||
if(isset($constraintData['column'])){
|
||||
$constraintData['column'] = (array)$constraintData['column'];
|
||||
}else{
|
||||
$constraintData['column'] = ['id'];
|
||||
}
|
||||
|
||||
$constraint = new Constraint($this->table, $this->name, $constraintData['table'], $constraintData['column']);
|
||||
|
||||
if(isset($constraintData['on-delete'])){
|
||||
$constraint->setOnDelete($constraintData['on-delete']);
|
||||
}
|
||||
|
||||
if(isset($constraintData['on-update'])){
|
||||
$constraint->setOnUpdate($constraintData['on-update']);
|
||||
}
|
||||
|
||||
}else{
|
||||
trigger_error(sprintf(self::TEXT_TableNameMissing, $this->table->name . '->' . $this->name));
|
||||
}
|
||||
|
||||
return $constraint;
|
||||
}
|
||||
}
|
||||
|
||||
class Constraint {
|
||||
|
||||
// available actions
|
||||
const ACTIONS_DELETE = ['RESTRICT', 'CASCADE', 'SET NULL', 'NO ACTION'];
|
||||
const ACTIONS_UPDATE = ['RESTRICT', 'CASCADE', 'SET NULL', 'NO ACTION'];
|
||||
|
||||
// default actions
|
||||
const ACTION_DELETE = 'RESTRICT';
|
||||
const ACTION_UPDATE = 'RESTRICT';
|
||||
|
||||
const TEXT_ActionNotSupported = 'Constraint action `%s` is not supported.';
|
||||
|
||||
protected $table;
|
||||
protected $keys = [];
|
||||
protected $referencedTable = '';
|
||||
protected $referencedCols = [];
|
||||
protected $onDelete = self::ACTION_DELETE;
|
||||
protected $onUpdate = self::ACTION_UPDATE;
|
||||
|
||||
/**
|
||||
* Constraint constructor.
|
||||
* @param SQL\TableBuilder $table
|
||||
* @param array $keys
|
||||
* @param string $referencedTable
|
||||
* @param array $referencedCols
|
||||
*/
|
||||
public function __construct(SQL\TableBuilder $table, $keys = [], $referencedTable = '', $referencedCols = ['id']){
|
||||
$this->table = &$table;
|
||||
$this->setKeys($keys);
|
||||
$this->setReferencedTable($referencedTable);
|
||||
$this->setReferencedCols($referencedCols);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $keys
|
||||
*/
|
||||
public function setKeys($keys){
|
||||
$this->keys = (array)$keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $referencedTable
|
||||
*/
|
||||
public function setReferencedTable($referencedTable){
|
||||
$this->referencedTable = $referencedTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $referencedCols
|
||||
*/
|
||||
public function setReferencedCols($referencedCols){
|
||||
$this->referencedCols = (array)$referencedCols;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $onDelete
|
||||
*/
|
||||
public function setOnDelete($onDelete){
|
||||
if( in_array($onDelete, self::ACTIONS_DELETE) ){
|
||||
$this->onDelete = $onDelete;
|
||||
}else{
|
||||
trigger_error(sprintf(self::TEXT_ActionNotSupported, $onDelete));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $onUpdate
|
||||
*/
|
||||
public function setOnUpdate($onUpdate){
|
||||
if( in_array($onUpdate, self::ACTIONS_UPDATE) ){
|
||||
$this->onUpdate = $onUpdate;
|
||||
}else{
|
||||
trigger_error(sprintf(self::TEXT_ActionNotSupported, $onUpdate));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getKeys(){
|
||||
return $this->keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReferencedTable(){
|
||||
return $this->referencedTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getReferencedCols(){
|
||||
return $this->referencedCols;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOnDelete(){
|
||||
return $this->onDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOnUpdate(){
|
||||
return $this->onUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* get a constraint name for this table.
|
||||
* This can either be used to generate unique constraint names for foreign keys in parent tables
|
||||
* or generate a "part" of a name. e.g. for db-Query all constraints of this table (ignore columns)
|
||||
* by "LIKE" selecting "information_schema"
|
||||
* -> To get a certain constraint or generate a unique constraint, ALL params are required!
|
||||
* @return string
|
||||
*/
|
||||
public function getConstraintName(){
|
||||
$constraintName = 'fk_' . $this->table->name;
|
||||
|
||||
if(!empty($this->getKeys())){
|
||||
$constraintName .= '___' . implode('__', $this->getKeys());
|
||||
if(!empty($this->getReferencedTable())){
|
||||
$constraintName .= '___' . $this->getReferencedTable();
|
||||
if(!empty($this->getReferencedCols())){
|
||||
$constraintName .= '___' . implode('__', $this->getReferencedCols());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $constraintName;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if constraint is valid
|
||||
* -> all required members must be set!
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(){
|
||||
$valid = false;
|
||||
|
||||
if(
|
||||
!empty($this->getKeys()) &&
|
||||
!empty($this->getReferencedTable()) &&
|
||||
!empty($this->getReferencedCols())
|
||||
){
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -38,11 +38,12 @@ abstract class AbstractPathfinderModel extends AbstractModel {
|
||||
|
||||
/**
|
||||
* @param bool $mapper
|
||||
* @param bool $essentials
|
||||
* @return NULL|void
|
||||
*/
|
||||
public function reset($mapper = true){
|
||||
public function reset($mapper = true, $essentials = true){
|
||||
$this->fieldChanges = [];
|
||||
parent::reset($mapper);
|
||||
parent::reset($mapper, $essentials);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,11 +148,12 @@ class TypeModel extends AbstractUniverseModel {
|
||||
|
||||
/**
|
||||
* @param bool $mapper
|
||||
* @param bool $essentials
|
||||
* @return NULL|void
|
||||
*/
|
||||
public function reset($mapper = true){
|
||||
public function reset($mapper = true, $essentials = true){
|
||||
$this->clearVirtual('dogmaAttributes');
|
||||
parent::reset($mapper);
|
||||
parent::reset($mapper, $essentials);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"ext-ctype": "*",
|
||||
"ext-gd": "*",
|
||||
"bcosca/fatfree-core": "3.7.*",
|
||||
"ikkez/f3-cortex": "dev-master#0d7754a5897a639e563add6b8d6db53fc0fae677",
|
||||
"ikkez/f3-cortex": "dev-master#af035616ae8d708776117e05603dac43835f3d9a",
|
||||
"ikkez/f3-sheet": "0.4.*",
|
||||
"xfra35/f3-cron": "1.2.*",
|
||||
"monolog/monolog": "2.*",
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"ext-ctype": "*",
|
||||
"ext-gd": "*",
|
||||
"bcosca/fatfree-core": "3.7.*",
|
||||
"ikkez/f3-cortex": "dev-master#0d7754a5897a639e563add6b8d6db53fc0fae677",
|
||||
"ikkez/f3-cortex": "dev-master#af035616ae8d708776117e05603dac43835f3d9a",
|
||||
"ikkez/f3-sheet": "0.4.*",
|
||||
"xfra35/f3-cron": "1.2.*",
|
||||
"monolog/monolog": "2.*",
|
||||
|
||||
137
composer.lock
generated
137
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "335a3680cd2d074fd048b76d16a6f4d2",
|
||||
"content-hash": "89a2596142e0f45259aabbf695e28de8",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bcosca/fatfree-core",
|
||||
@@ -1057,12 +1057,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ikkez/f3-cortex.git",
|
||||
"reference": "0d7754a5897a639e563add6b8d6db53fc0fae677"
|
||||
"reference": "af035616ae8d708776117e05603dac43835f3d9a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ikkez/f3-cortex/zipball/0d7754a5897a639e563add6b8d6db53fc0fae677",
|
||||
"reference": "0d7754a5897a639e563add6b8d6db53fc0fae677",
|
||||
"url": "https://api.github.com/repos/ikkez/f3-cortex/zipball/af035616ae8d708776117e05603dac43835f3d9a",
|
||||
"reference": "af035616ae8d708776117e05603dac43835f3d9a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1087,7 +1087,7 @@
|
||||
"orm",
|
||||
"sql"
|
||||
],
|
||||
"time": "2019-10-29T12:10:01+00:00"
|
||||
"time": "2020-04-07T09:55:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ikkez/f3-schema-builder",
|
||||
@@ -1163,16 +1163,16 @@
|
||||
},
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
"version": "1.0.66",
|
||||
"version": "1.0.67",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/flysystem.git",
|
||||
"reference": "021569195e15f8209b1c4bebb78bd66aa4f08c21"
|
||||
"reference": "5b1f36c75c4bdde981294c2a0ebdb437ee6f275e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/021569195e15f8209b1c4bebb78bd66aa4f08c21",
|
||||
"reference": "021569195e15f8209b1c4bebb78bd66aa4f08c21",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/5b1f36c75c4bdde981294c2a0ebdb437ee6f275e",
|
||||
"reference": "5b1f36c75c4bdde981294c2a0ebdb437ee6f275e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1243,7 +1243,7 @@
|
||||
"sftp",
|
||||
"storage"
|
||||
],
|
||||
"time": "2020-03-17T18:58:12+00:00"
|
||||
"time": "2020-04-16T13:21:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/html-to-markdown",
|
||||
@@ -1488,16 +1488,16 @@
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/log.git",
|
||||
"reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801"
|
||||
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801",
|
||||
"reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1531,7 +1531,7 @@
|
||||
"psr",
|
||||
"psr-3"
|
||||
],
|
||||
"time": "2019-11-01T11:05:21+00:00"
|
||||
"time": "2020-03-23T09:12:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/simple-cache",
|
||||
@@ -2059,16 +2059,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-iconv",
|
||||
"version": "v1.14.0",
|
||||
"version": "v1.15.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-iconv.git",
|
||||
"reference": "926832ce51059bb58211b7b2080a88e0c3b5328e"
|
||||
"reference": "ad6d62792bfbcfc385dd34b424d4fcf9712a32c8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/926832ce51059bb58211b7b2080a88e0c3b5328e",
|
||||
"reference": "926832ce51059bb58211b7b2080a88e0c3b5328e",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/ad6d62792bfbcfc385dd34b424d4fcf9712a32c8",
|
||||
"reference": "ad6d62792bfbcfc385dd34b424d4fcf9712a32c8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2080,7 +2080,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.14-dev"
|
||||
"dev-master": "1.15-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -2114,20 +2114,34 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2020-01-13T11:15:53+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-03-09T19:04:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-intl-idn",
|
||||
"version": "v1.14.0",
|
||||
"version": "v1.15.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-intl-idn.git",
|
||||
"reference": "6842f1a39cf7d580655688069a03dd7cd83d244a"
|
||||
"reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6842f1a39cf7d580655688069a03dd7cd83d244a",
|
||||
"reference": "6842f1a39cf7d580655688069a03dd7cd83d244a",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf",
|
||||
"reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2141,7 +2155,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.14-dev"
|
||||
"dev-master": "1.15-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -2176,20 +2190,34 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2020-01-17T12:01:36+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-03-09T19:04:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "v1.14.0",
|
||||
"version": "v1.15.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "34094cfa9abe1f0f14f48f490772db7a775559f2"
|
||||
"reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/34094cfa9abe1f0f14f48f490772db7a775559f2",
|
||||
"reference": "34094cfa9abe1f0f14f48f490772db7a775559f2",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac",
|
||||
"reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2201,7 +2229,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.14-dev"
|
||||
"dev-master": "1.15-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -2235,20 +2263,34 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2020-01-13T11:15:53+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-03-09T19:04:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php72",
|
||||
"version": "v1.14.0",
|
||||
"version": "v1.15.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php72.git",
|
||||
"reference": "46ecacf4751dd0dc81e4f6bf01dbf9da1dc1dadf"
|
||||
"reference": "37b0976c78b94856543260ce09b460a7bc852747"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/46ecacf4751dd0dc81e4f6bf01dbf9da1dc1dadf",
|
||||
"reference": "46ecacf4751dd0dc81e4f6bf01dbf9da1dc1dadf",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747",
|
||||
"reference": "37b0976c78b94856543260ce09b460a7bc852747",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2257,7 +2299,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.14-dev"
|
||||
"dev-master": "1.15-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -2290,7 +2332,21 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2020-01-13T11:15:53+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-02-27T09:26:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "xfra35/f3-cron",
|
||||
@@ -2348,5 +2404,6 @@
|
||||
"ext-ctype": "*",
|
||||
"ext-gd": "*"
|
||||
},
|
||||
"platform-dev": []
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "1.1.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user