Completed
Push — master ( 365595...fac0a1 )
by Morris
107:43 queued 92:43
created

DB::getErrorMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Bart Visscher <[email protected]>
6
 * @author Dan Bartram <[email protected]>
7
 * @author Frank Karlitschek <[email protected]>
8
 * @author Joas Schilling <[email protected]>
9
 * @author Jörn Friedrich Dreyer <[email protected]>
10
 * @author Lukas Reschke <[email protected]>
11
 * @author Morris Jobke <[email protected]>
12
 * @author Robin Appelman <[email protected]>
13
 * @author Roeland Jago Douma <[email protected]>
14
 * @author Thomas Müller <[email protected]>
15
 * @author Thomas Tanghus <[email protected]>
16
 *
17
 * @license AGPL-3.0
18
 *
19
 * This code is free software: you can redistribute it and/or modify
20
 * it under the terms of the GNU Affero General Public License, version 3,
21
 * as published by the Free Software Foundation.
22
 *
23
 * This program is distributed in the hope that it will be useful,
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
 * GNU Affero General Public License for more details.
27
 *
28
 * You should have received a copy of the GNU Affero General Public License, version 3,
29
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
30
 *
31
 */
32
33
/**
34
 * Public interface of ownCloud for apps to use.
35
 * DB Class
36
 *
37
 */
38
39
// use OCP namespace for all classes that are considered public.
40
// This means that they should be used by apps instead of the internal ownCloud classes
41
namespace OCP;
42
43
/**
44
 * This class provides access to the internal database system. Use this class exlusively if you want to access databases
45
 * @deprecated 8.1.0 use methods of \OCP\IDBConnection - \OC::$server->getDatabaseConnection()
46
 * @since 4.5.0
47
 */
48
class DB {
49
	/**
50
	 * Prepare a SQL query
51
	 * @param string $query Query string
52
	 * @param int $limit Limit of the SQL statement
53
	 * @param int $offset Offset of the SQL statement
54
	 * @return \OC_DB_StatementWrapper prepared SQL query
55
	 *
56
	 * SQL query via Doctrine prepare(), needs to be execute()'d!
57
	 * @deprecated 8.1.0 use prepare() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection()
58
	 * @since 4.5.0
59
	 */
60
	static public function prepare( $query, $limit=null, $offset=null ) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
61
		return \OC_DB::prepare($query, $limit, $offset);
62
	}
63
64
	/**
65
	 * Start a transaction
66
	 * @deprecated 8.1.0 use beginTransaction() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection()
67
	 * @since 4.5.0
68
	 */
69
	public static function beginTransaction() {
70
		\OC::$server->getDatabaseConnection()->beginTransaction();
71
	}
72
73
	/**
74
	 * Commit the database changes done during a transaction that is in progress
75
	 * @deprecated 8.1.0 use commit() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection()
76
	 * @since 4.5.0
77
	 */
78
	public static function commit() {
79
		\OC::$server->getDatabaseConnection()->commit();
80
	}
81
82
	/**
83
	 * returns the error code and message as a string for logging
84
	 * works with DoctrineException
85
	 * @return string
86
	 * @deprecated 8.1.0 use getError() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection()
87
	 * @since 6.0.0
88
	 */
89
	public static function getErrorMessage() {
90
		return \OC::$server->getDatabaseConnection()->getError();
91
	}
92
93
}
94