public static function get($db, $id, $id_field = 'id', $action_bookmark_all = false, $exact_user_match = false)
{
global $controllink;
$cfgBookmark = self::getParams();
if (empty($cfgBookmark)) {
return null;
}
$query = "SELECT * FROM " . Util::backquote($cfgBookmark['db']) . "." . Util::backquote($cfgBookmark['table']) . " WHERE dbase = '" . $GLOBALS['dbi']->escapeString($db) . "'";
if (!$action_bookmark_all) {
$query .= " AND (user = '" . $GLOBALS['dbi']->escapeString($cfgBookmark['user']) . "'";
if (!$exact_user_match) {
$query .= " OR user = ''";
}
$query .= ")";
}
$query .= " AND " . Util::backquote($id_field) . " = " . $GLOBALS['dbi']->escapeString($id) . " LIMIT 1";
$result = $GLOBALS['dbi']->fetchSingleRow($query, 'ASSOC', $controllink);
if (!empty($result)) {
$bookmark = new Bookmark();
$bookmark->_id = $result['id'];
$bookmark->_database = $result['dbase'];
$bookmark->_user = $result['user'];
$bookmark->_label = $result['label'];
$bookmark->_query = $result['query'];
return $bookmark;
}
return null;
}