PMA\libraries\Bookmark::getList PHP Метод

getList() публичный статический Метод

Gets the list of bookmarks defined for the current database
public static getList ( string | boolean $db = false ) : Bookmark[]
$db string | boolean the current database name or false
Результат Bookmark[] the bookmarks list
    public static function getList($db = false)
    {
        global $controllink;
        $cfgBookmark = self::getParams();
        if (empty($cfgBookmark)) {
            return array();
        }
        $query = "SELECT * FROM " . Util::backquote($cfgBookmark['db']) . "." . Util::backquote($cfgBookmark['table']) . " WHERE `user` = ''" . " OR `user` = '" . $GLOBALS['dbi']->escapeString($cfgBookmark['user']) . "'";
        if ($db !== false) {
            $query .= " AND dbase = '" . $GLOBALS['dbi']->escapeString($db) . "'";
        }
        $query .= " ORDER BY label";
        $result = $GLOBALS['dbi']->fetchResult($query, null, null, $controllink, DatabaseInterface::QUERY_STORE);
        if (!empty($result)) {
            $bookmarks = array();
            foreach ($result as $row) {
                $bookmark = new Bookmark();
                $bookmark->_id = $row['id'];
                $bookmark->_database = $row['dbase'];
                $bookmark->_user = $row['user'];
                $bookmark->_label = $row['label'];
                $bookmark->_query = $row['query'];
                $bookmarks[] = $bookmark;
            }
            return $bookmarks;
        }
        return array();
    }

Usage Example

Пример #1
0
 /**
  * Renders the bookmark content
  *
  * @access public
  * @return string
  */
 public static function getBookmarkContent()
 {
     $cfgBookmark = Bookmark::getParams();
     if ($cfgBookmark) {
         $bookmarks = Bookmark::getList();
         $count_bookmarks = count($bookmarks);
         if ($count_bookmarks > 0) {
             $welcomeMessage = sprintf(_ngettext('Showing %1$d bookmark (both private and shared)', 'Showing %1$d bookmarks (both private and shared)', $count_bookmarks), $count_bookmarks);
         } else {
             $welcomeMessage = __('No bookmarks');
         }
         unset($count_bookmarks, $private_message, $shared_message);
         return Template::get('console/bookmark_content')->render(array('welcomeMessage' => $welcomeMessage, 'bookmarks' => $bookmarks));
     }
     return '';
 }
All Usage Examples Of PMA\libraries\Bookmark::getList