\OCPDB

This class provides access to the internal database system. Use this class exlusively if you want to access databases

Summary

Methods
Properties
Constants
prepare()
insertIfNotExist()
insertid()
beginTransaction()
commit()
rollback()
isError()
getErrorMessage()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

prepare()

prepare(string  $query, integer  $limit = null, integer  $offset = null) : \OC_DB_StatementWrapper

Prepare a SQL query

Parameters

string $query

Query string

integer $limit

Limit of the SQL statement

integer $offset

Offset of the SQL statement

Returns

\OC_DB_StatementWrapper —

prepared SQL query

SQL query via Doctrine prepare(), needs to be execute()'d!

insertIfNotExist()

insertIfNotExist(string  $table, array  $input, array|null  $compare = null) : integer

Insert a row if the matching row does not exists.

Parameters

string $table

The table name (will replace PREFIX with the actual prefix)

array $input

data that should be inserted into the table (column name => value)

array|null $compare

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

Throws

\Doctrine\DBAL\DBALException

Returns

integer —

number of inserted rows

insertid()

insertid(string  $table = null) : string

Gets last value of autoincrement

Parameters

string $table

The optional table name (will replace PREFIX) and add sequence suffix

Returns

string —

\Doctrine\DBAL\Connection lastInsertID()

Call this method right after the insert command or other functions may cause trouble!

beginTransaction()

beginTransaction() 

Start a transaction

commit()

commit() 

Commit the database changes done during a transaction that is in progress

rollback()

rollback() 

Rollback the database changes done during a transaction that is in progress

isError()

isError(mixed  $result) : boolean

Check if a result is an error, works with Doctrine

Parameters

mixed $result

Returns

boolean

getErrorMessage()

getErrorMessage() : string

returns the error code and message as a string for logging works with DoctrineException

Returns

string