class Bookmark (View source)

Handles bookmarking SQL queries

Methods

__construct(DatabaseInterface $dbi, string $user)

No description

int
getId()

Returns the ID of the bookmark

string
getDatabase()

Returns the database of the bookmark

string
getUser()

Returns the user whom the bookmark belongs to

string
getLabel()

Returns the label of the bookmark

string
getQuery()

Returns the query

bool
save()

Adds a bookmark

bool
delete()

Deletes a bookmark

int
getVariableCount()

Returns the number of variables in a bookmark

string
applyVariables(array $variables)

Replace the placeholders in the bookmark query with variables

static array|bool
getParams(string $user)

Defines the bookmark parameters for the current user

static Bookmark|false
createBookmark(DatabaseInterface $dbi, string $user, array $bkm_fields, bool $all_users = false)

Creates a Bookmark object from the parameters

static Bookmark
createFromRow(DatabaseInterface $dbi, string $user, array $row)

No description

static array
getList(DatabaseInterface $dbi, string $user, string|bool $db = false)

Gets the list of bookmarks defined for the current database

static Bookmark|null
get(DatabaseInterface $dbi, string $user, string $db, int|string $id, string $id_field = 'id', bool $action_bookmark_all = false, bool $exact_user_match = false)

Retrieve a specific bookmark

Details

__construct(DatabaseInterface $dbi, string $user)

Parameters

DatabaseInterface $dbi DatabaseInterface object
string $user Current user

int getId()

Returns the ID of the bookmark

Return Value

int

string getDatabase()

Returns the database of the bookmark

Return Value

string

string getUser()

Returns the user whom the bookmark belongs to

Return Value

string

string getLabel()

Returns the label of the bookmark

Return Value

string

string getQuery()

Returns the query

Return Value

string

bool save()

Adds a bookmark

Return Value

bool whether the INSERT succeeds or not

bool delete()

Deletes a bookmark

Return Value

bool true if successful

int getVariableCount()

Returns the number of variables in a bookmark

Return Value

int number of variables

string applyVariables(array $variables)

Replace the placeholders in the bookmark query with variables

Parameters

array $variables array of variables

Return Value

string query with variables applied

static array|bool getParams(string $user)

Defines the bookmark parameters for the current user

Parameters

string $user Current user

Return Value

array|bool the bookmark parameters for the current user

static Bookmark|false createBookmark(DatabaseInterface $dbi, string $user, array $bkm_fields, bool $all_users = false)

Creates a Bookmark object from the parameters

Parameters

DatabaseInterface $dbi DatabaseInterface object
string $user Current user
array $bkm_fields the properties of the bookmark to add; here, $bkm_fields['bkm_sql_query'] is urlencoded
bool $all_users whether to make the bookmark available for all users

Return Value

Bookmark|false

static protected Bookmark createFromRow(DatabaseInterface $dbi, string $user, array $row)

Parameters

DatabaseInterface $dbi DatabaseInterface object
string $user Current user
array $row Resource used to build the bookmark

Return Value

Bookmark

static array getList(DatabaseInterface $dbi, string $user, string|bool $db = false)

Gets the list of bookmarks defined for the current database

Parameters

DatabaseInterface $dbi DatabaseInterface object
string $user Current user
string|bool $db the current database name or false

Return Value

array the bookmarks list

static Bookmark|null get(DatabaseInterface $dbi, string $user, string $db, int|string $id, string $id_field = 'id', bool $action_bookmark_all = false, bool $exact_user_match = false)

Retrieve a specific bookmark

Parameters

DatabaseInterface $dbi DatabaseInterface object
string $user Current user
string $db the current database name
int|string $id an identifier of the bookmark to get
string $id_field which field to look up the identifier
bool $action_bookmark_all true: get all bookmarks regardless of the owning user
bool $exact_user_match whether to ignore bookmarks with no user

Return Value

Bookmark|null the bookmark