Passed
Push — master ( 9e15fe...1d956f )
by Jean-Christophe
09:32
created

AbstractDbWrapper::close()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 2
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Ubiquity\db\providers;
4
5
/**
6
 * Ubiquity\db\providers$AbstractDbWrapper
7
 * This class is part of Ubiquity
8
 *
9
 * @author jcheron <[email protected]>
10
 * @version 1.0.0
11
 *
12
 */
13
abstract class AbstractDbWrapper {
14
	protected $dbInstance;
15
	protected $statements;
16
	public $quote;
17
18
	abstract public function query(string $sql);
19
20
	abstract public function queryAll(string $sql, int $fetchStyle = null);
21
22
	abstract public function queryColumn(string $sql, int $columnNumber = null);
23
24
	abstract public static function getAvailableDrivers();
25
26 67
	public function _getStatement(string $sql) {
27 67
		if (! isset ( $this->statements [$sql] )) {
28 67
			$this->statements [$sql] = $this->getStatement ( $sql );
29
		}
30 67
		return $this->statements [$sql];
31
	}
32
33
	abstract public function getStatement(string $sql);
34
35
	abstract public function connect(string $dbType, $dbName, $serverName, string $port, string $user, string $password, array $options);
36
37
	abstract public function getDSN(string $serverName, string $port, string $dbName, string $dbType = 'mysql');
38
39
	abstract public function execute(string $sql);
40
41
	abstract public function prepareStatement(string $sql);
42
43
	abstract public function executeStatement($statement, array $values = null);
44
45
	abstract public function statementRowCount($statement);
46
47
	abstract public function lastInsertId();
48
49
	/**
50
	 * Used by DAO
51
	 *
52
	 * @param mixed $statement
53
	 * @param string $parameter
54
	 * @param mixed $value
55
	 */
56
	abstract public function bindValueFromStatement($statement, $parameter, $value);
57
58
	abstract public function fetchColumn($statement, array $values = null, int $columnNumber = null);
59
60
	abstract public function fetchAll($statement, array $values = null, $mode = null);
61
62
	abstract public function fetchOne($statement, array $values = null, $mode = null);
63
64
	abstract public function fetchAllColumn($statement, array $values = null, string $column = null);
65
66
	abstract public function getTablesName();
67
68
	abstract public function beginTransaction();
69
70
	abstract public function commit();
71
72
	abstract public function inTransaction();
73
74
	abstract public function rollBack();
75
76
	abstract public function nestable();
77
78
	abstract public function savePoint($level);
79
80
	abstract public function releasePoint($level);
81
82
	abstract public function rollbackPoint($level);
83
84
	abstract public function ping();
85
86
	abstract public function getPrimaryKeys($tableName);
87
88
	abstract public function getFieldsInfos($tableName);
89
90
	abstract public function getForeignKeys($tableName, $pkName, $dbName = null);
91
92
	abstract public function _optPrepareAndExecute($sql, array $values = null);
93
94 23
	public function close() {
95 23
		$this->dbInstance = null;
96 23
	}
97
98
	/**
99
	 *
100
	 * @return object
101
	 */
102 1
	public function getDbInstance() {
103 1
		return $this->dbInstance;
104
	}
105
106
	/**
107
	 *
108
	 * @param object $dbInstance
109
	 */
110
	public function setDbInstance($dbInstance) {
111
		$this->dbInstance = $dbInstance;
112
	}
113
}