get() public static method

Retrieve a specific bookmark
public static get ( string $db, mixed $id, string $id_field = 'id', boolean $action_bookmark_all = false, boolean $exact_user_match = false ) : Bookmark
$db string the current database name
$id mixed an identifier of the bookmark to get
$id_field string which field to look up the identifier
$action_bookmark_all boolean true: get all bookmarks regardless of the owning user
$exact_user_match boolean whether to ignore bookmarks with no user
return Bookmark the bookmark
Ejemplo n.º 1
0
 /**
  * Tests for Bookmark::get()
  *
  * @return void
  */
 public function testGet()
 {
     $this->assertNull(Bookmark::get('phpmyadmin', '1'));
 }
Ejemplo n.º 2
0
     $import_text = $bookmark->getQuery();
     if ($GLOBALS['is_ajax_request'] == true) {
         $message = PMA\libraries\Message::success(__('Showing bookmark'));
         $response = PMA\libraries\Response::getInstance();
         $response->setRequestStatus($message->isSuccess());
         $response->addJSON('message', $message);
         $response->addJSON('sql_query', $import_text);
         $response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
         exit;
     } else {
         $run_query = false;
     }
     break;
 case 2:
     // bookmarked query that have to be deleted
     $bookmark = Bookmark::get($db, $id_bookmark);
     if (!empty($bookmark)) {
         $bookmark->delete();
         if ($GLOBALS['is_ajax_request'] == true) {
             $message = PMA\libraries\Message::success(__('The bookmark has been deleted.'));
             $response = PMA\libraries\Response::getInstance();
             $response->setRequestStatus($message->isSuccess());
             $response->addJSON('message', $message);
             $response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
             $response->addJSON('id_bookmark', $id_bookmark);
             exit;
         } else {
             $run_query = false;
             $error = true;
             // this is kind of hack to skip processing the query
         }
Ejemplo n.º 3
0
/**
 * Function to get the default sql query for browsing page
 *
 * @param String $db    the current database
 * @param String $table the current table
 *
 * @return String $sql_query the default $sql_query for browse page
 */
function PMA_getDefaultSqlQueryForBrowse($db, $table)
{
    $bookmark = Bookmark::get($db, $table, 'label', false, true);
    if (!empty($bookmark) && !empty($bookmark->getQuery())) {
        $GLOBALS['using_bookmark_message'] = Message::notice(__('Using bookmark "%s" as default browse query.'));
        $GLOBALS['using_bookmark_message']->addParam($table);
        $GLOBALS['using_bookmark_message']->addMessage(PMA\libraries\Util::showDocu('faq', 'faq6-22'));
        $sql_query = $bookmark->getQuery();
    } else {
        $defaultOrderByClause = '';
        if (isset($GLOBALS['cfg']['TablePrimaryKeyOrder']) && $GLOBALS['cfg']['TablePrimaryKeyOrder'] !== 'NONE') {
            $primaryKey = null;
            $primary = PMA\libraries\Index::getPrimary($table, $db);
            if ($primary !== false) {
                $primarycols = $primary->getColumns();
                foreach ($primarycols as $col) {
                    $primaryKey = $col->getName();
                    break;
                }
                if ($primaryKey != null) {
                    $defaultOrderByClause = ' ORDER BY ' . PMA\libraries\Util::backquote($table) . '.' . PMA\libraries\Util::backquote($primaryKey) . ' ' . $GLOBALS['cfg']['TablePrimaryKeyOrder'];
                }
            }
        }
        $sql_query = 'SELECT * FROM ' . PMA\libraries\Util::backquote($table) . $defaultOrderByClause;
    }
    return $sql_query;
}