Properties

$_cache

$_cache : array

cache for select queries

Type

array

$_db

$_db : \PDO

instance of database connection

Type

\PDO

$_prefix

$_prefix : string

table prefix

Type

string

$_type

$_type : string

database type

Type

string

Methods

getInstance()

getInstance(array  $options = null) : \PrivateBin\Data\Database

get instance of singleton

Parameters

array $options

Throws

\Exception

Returns

\PrivateBin\Data\Database

create()

create(string  $pasteid, array  $paste) : boolean

Create a paste.

Parameters

string $pasteid
array $paste

Returns

boolean

read()

read(string  $pasteid) : \stdClass|false

Read a paste.

Parameters

string $pasteid

Returns

\stdClass|false

delete()

delete(string  $pasteid) 

Delete a paste and its discussion.

Parameters

string $pasteid

exists()

exists(string  $pasteid) : boolean

Test if a paste exists.

Parameters

string $pasteid

Returns

boolean

createComment()

createComment(string  $pasteid, string  $parentid, string  $commentid, array  $comment) : boolean

Create a comment in a paste.

Parameters

string $pasteid
string $parentid
string $commentid
array $comment

Returns

boolean

readComments()

readComments(string  $pasteid) : array

Read all comments of paste.

Parameters

string $pasteid

Returns

array

existsComment()

existsComment(string  $pasteid, string  $parentid, string  $commentid) : boolean

Test if a comment exists.

Parameters

string $pasteid
string $parentid
string $commentid

Returns

boolean

purge()

purge(integer  $batchsize) 

Perform a purge of old pastes, at most the given batchsize is deleted.

Parameters

integer $batchsize

__construct()

__construct() 

enforce singleton, disable constructor

Instantiate using \getInstance(), privatebin is a singleton object.

_getExpiredPastes()

_getExpiredPastes(integer  $batchsize) : array

Returns up to batch size number of paste ids that have expired

Parameters

integer $batchsize

Returns

array

getOpenSlot()

getOpenSlot(array  $comments, integer|string  $postdate) : integer|string

Get next free slot for comment from postdate.

Parameters

array $comments
integer|string $postdate

Returns

integer|string

__clone()

__clone() 

enforce singleton, disable cloning

Instantiate using \getInstance(), privatebin is a singleton object.

_exec()

_exec(string  $sql, array  $params) : boolean

execute a statement

Parameters

string $sql
array $params

Throws

\PDOException

Returns

boolean

_select()

_select(string  $sql, array  $params, boolean  $firstOnly = false) : array

run a select statement

Parameters

string $sql
array $params
boolean $firstOnly

if only the first row should be returned

Throws

\PDOException

Returns

array

_getTableQuery()

_getTableQuery(string  $type) : string

get table list query, depending on the database type

Parameters

string $type

Throws

\Exception

Returns

string

_getConfig()

_getConfig(string  $key) : string

get a value by key from the config table

Parameters

string $key

Throws

\PDOException

Returns

string

_getPrimaryKeyClauses()

_getPrimaryKeyClauses(string  $key = 'dataid') : array

get the primary key clauses, depending on the database driver

Parameters

string $key

Returns

array

_createPasteTable()

_createPasteTable() 

create the paste table

_createCommentTable()

_createCommentTable() 

create the paste table

_createConfigTable()

_createConfigTable() 

create the paste table

_sanitizeIdentifier()

_sanitizeIdentifier(string  $identifier) : string

sanitizes identifiers

Parameters

string $identifier

Returns

string

_upgradeDatabase()

_upgradeDatabase(string  $oldversion) 

upgrade the database schema from an old version

Parameters

string $oldversion