|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ubiquity\db\providers\pdo\drivers; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Ubiquity\db\providers$DriverMetaDatas |
|
7
|
|
|
* This class is part of Ubiquity |
|
8
|
|
|
* |
|
9
|
|
|
* @author jc |
|
10
|
|
|
* @version 1.0.3 |
|
11
|
|
|
* |
|
12
|
|
|
*/ |
|
13
|
|
|
abstract class AbstractDriverMetaDatas { |
|
14
|
|
|
protected $dbInstance; |
|
15
|
|
|
protected $operations; |
|
16
|
|
|
|
|
17
|
43 |
|
public function __construct($dbInstance) { |
|
18
|
43 |
|
$this->dbInstance = $dbInstance; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Returns all table names in the database. |
|
23
|
|
|
* |
|
24
|
|
|
* @return array |
|
25
|
|
|
*/ |
|
26
|
|
|
abstract public function getTablesName(): array; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Returns an array of the primary keys field names. |
|
30
|
|
|
* |
|
31
|
|
|
* @param string $tableName |
|
32
|
|
|
* @return array |
|
33
|
|
|
*/ |
|
34
|
|
|
abstract public function getPrimaryKeys(string $tableName): array; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Returns the list of foreign keys in a table. |
|
38
|
|
|
* |
|
39
|
|
|
* @param string $tableName |
|
40
|
|
|
* @param string $pkName |
|
41
|
|
|
* @param string $dbName |
|
42
|
|
|
* @return array |
|
43
|
|
|
*/ |
|
44
|
|
|
abstract public function getForeignKeys(string $tableName, string $pkName, ?string $dbName = null): array; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Returns metadata related to the fields of the specified table. |
|
48
|
|
|
* |
|
49
|
|
|
* @param string $tableName |
|
50
|
|
|
* @return array |
|
51
|
|
|
*/ |
|
52
|
|
|
abstract public function getFieldsInfos(string $tableName): array; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Returns the line number of a data record. |
|
56
|
|
|
* |
|
57
|
|
|
* @param string $tableName |
|
58
|
|
|
* @param string $pkName |
|
59
|
|
|
* @param string $condition |
|
60
|
|
|
* @return int |
|
61
|
|
|
*/ |
|
62
|
|
|
abstract public function getRowNum(string $tableName, string $pkName, string $condition): int; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Returns the SQL callback for fields concatenation |
|
66
|
|
|
* |
|
67
|
|
|
* @param string $fields |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
|
|
abstract public function groupConcat(string $fields, string $separator): string; |
|
71
|
|
|
|
|
72
|
35 |
|
public function toStringOperator() { |
|
73
|
35 |
|
return ''; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function getPHPType(string $dbType): string { |
|
77
|
|
|
return ''; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Returns the SQL string for a migration operation. |
|
82
|
|
|
* @param string $operation |
|
83
|
|
|
* @return string |
|
84
|
|
|
*/ |
|
85
|
1 |
|
public function migrateOperation(string $operation):?string{ |
|
86
|
1 |
|
return $this->operations[$operation]??null; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Sets the isolation level for transactions. |
|
91
|
|
|
* @param $isolationLevel |
|
92
|
|
|
* @return mixed |
|
93
|
|
|
*/ |
|
94
|
|
|
public function setIsolationLevel($isolationLevel) { |
|
95
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
|