Adapter¶
-
class
OC\DB\
Adapter
¶ - This handles the way we use to write queries, into something that can behandled by the database abstraction layer.
Source: lib/private/DB/Adapter.php#40
Properties¶
-
protected static property
OC\DB\Adapter::$
conn
¶ Source: lib/private/DB/Adapter.php#45 Type: \OC\DB\Connection
Methods¶
-
public
OC\DB\Adapter::
__construct
($conn)¶ Source: lib/private/DB/Adapter.php#47
-
public
OC\DB\Adapter::
lastInsertId
($table)¶ Source: Parameters: - $table (string) name
Returns: int id of last insert statement
Throws: \Doctrine\DBAL\Exception
-
public
OC\DB\Adapter::
fixupStatement
($statement)¶ Source: Parameters: - $statement (string) that needs to be changed so the db can handle it
Returns: string changed statement
-
public
OC\DB\Adapter::
lockTable
($tableName)¶ - Create an exclusive read+write lock on a table
Source: Parameters: - $tableName (string)
Throws: \Doctrine\DBAL\Exception
Since: 9.1.0
-
public
OC\DB\Adapter::
unlockTable
()¶ - Release a previous acquired lock again
Source: lib/private/DB/Adapter.php#87 Throws: \Doctrine\DBAL\Exception
Since: 9.1.0
-
public
OC\DB\Adapter::
insertIfNotExist
($table, $input, $compare=null)¶ - Insert a row if the matching row does not exists. To accomplish proper race condition avoidanceit is needed that there is also a unique constraint on the values. Then this method willcatch the exception and return 0.
Source: Parameters: - $table (string) The table name (will replace PREFIX with the actual prefix)
- $input (array) data that should be inserted into the table (column name => value)
- $compare (array | null) List of values that should be checked for “if not exists”
If this is null or an empty array, all keys of $input will be compared Please note: text fields (clob) must not be used in the compare array
Returns: int number of inserted rows
Throws: \Doctrine\DBAL\Exception
Deprecated: 15.0.0 - use unique index and “try { $db->insert() } catch (UniqueConstraintViolationException $e) }” instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371
-
public
OC\DB\Adapter::
insertIgnoreConflict
($table, $values)¶ Source: lib/private/DB/Adapter.php#141 Throws: \OCP\DB\Exception