-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from WebFiori/dev
Enhancement For Building Relations
- Loading branch information
Showing
7 changed files
with
191 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* This file is licensed under MIT License. | ||
* | ||
* Copyright (c) 2023 Ibrahim BinAlshikh | ||
* | ||
* For more information on the license, please visit: | ||
* https://github.com/WebFiori/.github/blob/main/LICENSE | ||
* | ||
*/ | ||
namespace webfiori\database; | ||
|
||
/** | ||
* A class that represents a foreign key. | ||
* | ||
* A foreign key must have an owner table and a source table. The | ||
* source table will contain original values and the owner is simply the table | ||
* that own the key. | ||
* | ||
* @author Ibrahim | ||
*/ | ||
class FK extends ForeignKey { | ||
/** | ||
* An action that can be performed on update or delete. | ||
* | ||
* @var string | ||
*/ | ||
const SET_NULL = 'set null'; | ||
/** | ||
* An action that can be performed on update or delete. | ||
* | ||
* @var string | ||
*/ | ||
const SET_DEFAULT = 'set default'; | ||
/** | ||
* An action that can be performed on update or delete. | ||
* | ||
* @var string | ||
*/ | ||
const NO_ACTION = 'no action'; | ||
/** | ||
* An action that can be performed on update or delete. | ||
* | ||
* @var string | ||
*/ | ||
const CASCADE = 'cascade'; | ||
/** | ||
* An action that can be performed on update or delete. | ||
* | ||
* @var string | ||
*/ | ||
const RESTRICT = 'restrict'; | ||
/** | ||
* Creates new foreign key. | ||
* | ||
* @param string $name The name of the key. It must be a string, and it's not empty. | ||
* Also, it must not contain any spaces or any characters other than A-Z, a-z and | ||
* underscore. The default value is 'key_name'. | ||
* | ||
* @param Table $ownerTable The table that will contain the key. | ||
* | ||
* @param Table $sourceTable The name of the table that contains the | ||
* original values. | ||
* | ||
* @param array $cols An associative array that contains the names of key | ||
* columns. The indices must be columns in the owner table and the values are | ||
* columns in the source table. | ||
* | ||
* @throws DatabaseException If one of the tables of the foreign key is not set. | ||
*/ | ||
public function __construct(string $name = 'key_name', Table $ownerTable = null, Table $sourceTable = null, array $cols = []) { | ||
parent::__construct($name, $ownerTable, $sourceTable, $cols); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
* | ||
* @author Ibrahim | ||
* | ||
* @version 1.0 | ||
* @deprecated Use the class FK. | ||
*/ | ||
class ForeignKey { | ||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters