1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ubiquity\db\traits; |
4
|
|
|
|
5
|
|
|
use Ubiquity\db\utils\DbTypes; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Retreives metadatas from the database. |
9
|
|
|
* |
10
|
|
|
* Ubiquity\db\traits$DatabaseMetadatas |
11
|
|
|
* This class is part of Ubiquity |
12
|
|
|
* |
13
|
|
|
* @author jcheron <[email protected]> |
14
|
|
|
* @version 1.0.4 |
15
|
|
|
* |
16
|
|
|
* @property \Ubiquity\db\providers\AbstractDbWrapper $wrapperObject |
17
|
|
|
*/ |
18
|
|
|
trait DatabaseMetadatas { |
19
|
|
|
|
20
|
4 |
|
public function getTablesName() { |
21
|
4 |
|
return $this->wrapperObject->getTablesName (); |
22
|
|
|
} |
23
|
|
|
|
24
|
1 |
|
public function getPrimaryKeys($tableName) { |
25
|
1 |
|
return $this->wrapperObject->getPrimaryKeys ( $tableName ); |
26
|
|
|
} |
27
|
|
|
|
28
|
1 |
|
public function getFieldsInfos($tableName) { |
29
|
1 |
|
return $this->wrapperObject->getFieldsInfos ( $tableName ); |
30
|
|
|
} |
31
|
|
|
|
32
|
1 |
|
public function getForeignKeys($tableName, $pkName, $dbName = null) { |
33
|
1 |
|
return $this->wrapperObject->getForeignKeys ( $tableName, $pkName, $dbName ); |
34
|
|
|
} |
35
|
|
|
|
36
|
4 |
|
public function getRowNum(string $tableName, string $pkName, string $condition): int { |
37
|
4 |
|
return $this->wrapperObject->getRowNum ( $tableName, $pkName, $condition ); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function getPHPType(string $dbType): string { |
41
|
|
|
return DbTypes::asPhpType($dbType); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Returns the SQL command for a migration operation. |
46
|
|
|
* @param string $operation The migration to opere |
47
|
|
|
* @return string The generated SQL string |
48
|
|
|
*/ |
49
|
|
|
public function migrateOperation(string $operation):string { |
50
|
|
|
return $this->wrapperObject->migrateOperation($operation); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
|