-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_tableAccess.php
More file actions
68 lines (52 loc) · 1.46 KB
/
_tableAccess.php
File metadata and controls
68 lines (52 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/orm/blob/master/LICENSE
*/
namespace Quid\Orm;
// _tableAccess
// trait that grants table access to the class using
trait _tableAccess
{
// trait
use _dbAccess;
// dynamique
protected ?string $table = null; // objet table
// setLink
// set la table et db à l'objet
// envoie une exception si l'objet existe déjà
final protected function setLink(Table $value,bool $checkLink=false):void
{
$this->setDb($value->db());
$this->table = $value->name();
if($checkLink === true && $this->isLinked())
static::throw('alreadyInstantiated');
}
// tableName
// retourne la propriété protégé table
final public function tableName():string
{
return $this->table;
}
// tables
// retourne l'objet tables
final public function tables():Tables
{
return $this->db()->tables();
}
// table
// retourne l'objet table
final public function table():Table
{
return $this->db()->table($this->table);
}
// sameTable
// retourne vrai si l'objet et celui fourni ont la même table
final public function sameTable($table):bool
{
return $this->db()->hasTable($table) && $this->table() === $this->db()->table($table);
}
}
?>