PMA\libraries\SavedSearches::getList PHP 메소드

getList() 공개 메소드

Get the list of saved searches of a user on a DB
public getList ( array $wheres = [] ) : array
$wheres array List of filters
리턴 array List of saved searches or empty array on failure
    public function getList(array $wheres = array())
    {
        if (null == $this->getUsername() || null == $this->getDbname()) {
            return array();
        }
        $savedSearchesTbl = Util::backquote($this->_config['cfgRelation']['db']) . "." . Util::backquote($this->_config['cfgRelation']['savedsearches']);
        $sqlQuery = "SELECT id, search_name " . "FROM " . $savedSearchesTbl . " " . "WHERE " . "username = '" . $GLOBALS['dbi']->escapeString($this->getUsername()) . "' " . "AND db_name = '" . $GLOBALS['dbi']->escapeString($this->getDbname()) . "' ";
        foreach ($wheres as $where) {
            $sqlQuery .= "AND " . $where . " ";
        }
        $sqlQuery .= "order by search_name ASC ";
        $resList = PMA_queryAsControlUser($sqlQuery);
        $list = array();
        while ($oneResult = $GLOBALS['dbi']->fetchArray($resList)) {
            $list[$oneResult['id']] = $oneResult['search_name'];
        }
        return $list;
    }

Usage Example

예제 #1
0
파일: db_qbe.php 프로젝트: poush/phpmyadmin
            $savedSearch = new SavedSearches($GLOBALS);
            $savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])->setDbname($_REQUEST['db']);
            $_REQUEST = array();
        } elseif ('load' === $_REQUEST['action']) {
            if (empty($_REQUEST['searchId'])) {
                //when not loading a search, reset the object.
                $savedSearch = new SavedSearches($GLOBALS);
                $savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])->setDbname($_REQUEST['db']);
                $_REQUEST = array();
            } else {
                $loadResult = $savedSearch->load();
            }
        }
        //Else, it's an "update query"
    }
    $savedSearchList = $savedSearch->getList();
    $currentSearchId = $savedSearch->getId();
}
/**
 * A query has been submitted -> (maybe) execute it
 */
$message_to_display = false;
if (isset($_REQUEST['submit_sql']) && !empty($sql_query)) {
    if (!preg_match('@^SELECT@i', $sql_query)) {
        $message_to_display = true;
    } else {
        $goto = 'db_sql.php';
        PMA_executeQueryAndSendQueryResponse(null, false, $_REQUEST['db'], null, false, null, null, null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query, null, null);
    }
}
$sub_part = '_qbe';