当前位置: 首页>>代码示例>>PHP>>正文


PHP Filter::escapeLike方法代码示例

本文整理汇总了PHP中Fisharebest\Webtrees\Filter::escapeLike方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::escapeLike方法的具体用法?PHP Filter::escapeLike怎么用?PHP Filter::escapeLike使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fisharebest\Webtrees\Filter的用法示例。


在下文中一共展示了Filter::escapeLike方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: all_media_files

/**
 * Fetch a list of all files on in the database.
 *
 * The subfolders parameter is not implemented. However, as we
 * currently use this function as an exclusion list, it is harmless
 * to always include sub-folders.
 *
 * @param string $media_folder
 * @param string $media_path
 * @param string $subfolders
 * @param string $filter
 *
 * @return string[]
 */
function all_media_files($media_folder, $media_path, $subfolders, $filter)
{
    return Database::prepare("SELECT SQL_CACHE SQL_CALC_FOUND_ROWS TRIM(LEADING :media_path_1 FROM m_filename) AS media_path, 'OBJE' AS type, m_titl, m_id AS xref, m_file AS ged_id, m_gedcom AS gedrec, m_filename" . " FROM  `##media`" . " JOIN  `##gedcom_setting` ON (m_file = gedcom_id AND setting_name = 'MEDIA_DIRECTORY')" . " JOIN  `##gedcom`         USING (gedcom_id)" . " WHERE setting_value = :media_folder" . " AND   m_filename LIKE CONCAT(:media_path_2, '%')" . " AND   (SUBSTRING_INDEX(m_filename, '/', -1) LIKE CONCAT('%', :filter_1, '%')" . "  OR   m_titl LIKE CONCAT('%', :filter_2, '%'))" . " AND   m_filename NOT LIKE 'http://%'" . " AND   m_filename NOT LIKE 'https://%'")->execute(array('media_path_1' => $media_path, 'media_folder' => $media_folder, 'media_path_2' => Filter::escapeLike($media_path), 'filter_1' => Filter::escapeLike($filter), 'filter_2' => Filter::escapeLike($filter)))->fetchOneColumn();
}
开发者ID:tronsmit,项目名称:webtrees,代码行数:18,代码来源:admin_media.php

示例2: searchRepositories

 /**
  * Search the repositories
  *
  * @param string[] $query Search terms
  * @param Tree[] $trees The trees to search
  *
  * @return Repository[]
  */
 public static function searchRepositories(array $query, array $trees)
 {
     // Convert the query into a regular expression
     $queryregex = array();
     $sql = "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom FROM `##other` WHERE o_type = 'REPO'";
     $args = array();
     foreach ($query as $n => $q) {
         $queryregex[] = preg_quote(I18N::strtoupper($q), '/');
         $sql .= " AND o_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')";
         $args['collate_' . $n] = I18N::collation();
         $args['query_' . $n] = Filter::escapeLike($q);
     }
     $sql .= " AND o_file IN (";
     foreach ($trees as $n => $tree) {
         $sql .= $n ? ", " : "";
         $sql .= ":tree_id_" . $n;
         $args['tree_id_' . $n] = $tree->getTreeId();
     }
     $sql .= ")";
     $list = array();
     $rows = Database::prepare($sql)->execute($args)->fetchAll();
     foreach ($rows as $row) {
         // SQL may have matched on private data or gedcom tags, so check again against privatized data.
         $record = Repository::getInstance($row->xref, Tree::findById($row->gedcom_id), $row->gedcom);
         // Ignore non-genealogy data
         $gedrec = preg_replace('/\\n\\d (_UID|_WT_USER|FILE|FORM|TYPE|CHAN|REFN|RESN) .*/', '', $record->getGedcom());
         // Ignore links and tags
         $gedrec = preg_replace('/\\n\\d ' . WT_REGEX_TAG . '( @' . WT_REGEX_XREF . '@)?/', '', $gedrec);
         // Ignore tags
         $gedrec = preg_replace('/\\n\\d ' . WT_REGEX_TAG . ' ?/', '', $gedrec);
         // Re-apply the filtering
         $gedrec = I18N::strtoupper($gedrec);
         foreach ($queryregex as $regex) {
             if (!preg_match('/' . $regex . '/', $gedrec)) {
                 continue 2;
             }
         }
         $list[] = $record;
     }
     $list = array_filter($list, function (Repository $x) {
         return $x->canShowName();
     });
     return $list;
 }
开发者ID:pal-saugstad,项目名称:webtrees,代码行数:52,代码来源:FunctionsDb.php

示例3: mediaList

 /**
  * Generate a filtered, sourced, privacy-checked list of media objects - for the media list.
  *
  * @param string $folder     folder to search
  * @param string $subfolders either "include" or "exclude"
  * @param string $sort       either "file" or "title"
  * @param string $filter     optional search string
  * @param string $form_type  option OBJE/FILE/FORM/TYPE
  *
  * @throws \Exception
  *
  * @return Media[]
  */
 public static function mediaList($folder, $subfolders, $sort, $filter, $form_type)
 {
     global $WT_TREE;
     // All files in the folder, plus external files
     $sql = "SELECT m_id AS xref, m_gedcom AS gedcom" . " FROM `##media`" . " WHERE m_file=?";
     $args = array($WT_TREE->getTreeId());
     // Only show external files when we are looking at the root folder
     if ($folder == '') {
         $sql_external = " OR m_filename LIKE 'http://%' OR m_filename LIKE 'https://%'";
     } else {
         $sql_external = "";
     }
     // Include / exclude subfolders (but always include external)
     switch ($subfolders) {
         case 'include':
             $sql .= " AND (m_filename LIKE CONCAT(?, '%') {$sql_external})";
             $args[] = Filter::escapeLike($folder);
             break;
         case 'exclude':
             $sql .= " AND (m_filename LIKE CONCAT(?, '%')  AND m_filename NOT LIKE CONCAT(?, '%/%') {$sql_external})";
             $args[] = Filter::escapeLike($folder);
             $args[] = Filter::escapeLike($folder);
             break;
         default:
             throw new \Exception('Bad argument (subfolders=' . $subfolders . ') in QueryMedia::mediaList()');
     }
     // Apply search terms
     if ($filter) {
         $sql .= " AND (SUBSTRING_INDEX(m_filename, '/', -1) LIKE CONCAT('%', ?, '%') OR m_titl LIKE CONCAT('%', ?, '%'))";
         $args[] = Filter::escapeLike($filter);
         $args[] = Filter::escapeLike($filter);
     }
     if ($form_type) {
         $sql .= " AND (m_gedcom LIKE CONCAT('%\n3 TYPE ', ?, '%'))";
         $args[] = $form_type;
     }
     switch ($sort) {
         case 'file':
             $sql .= " ORDER BY m_filename";
             break;
         case 'title':
             $sql .= " ORDER BY m_titl";
             break;
         default:
             throw new \Exception('Bad argument (sort=' . $sort . ') in QueryMedia::mediaList()');
     }
     $rows = Database::prepare($sql)->execute($args)->fetchAll();
     $list = array();
     foreach ($rows as $row) {
         $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
         if ($media->canShow()) {
             $list[] = $media;
         }
     }
     return $list;
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:69,代码来源:QueryMedia.php

示例4: array

switch ($action) {
    case 'load':
        // AJAX callback for datatables
        $search = Filter::get('search');
        $search = $search['value'];
        $start = Filter::getInteger('start');
        $length = Filter::getInteger('length');
        $sql = "SELECT SQL_CACHE SQL_CALC_FOUND_ROWS" . " '', INET_NTOA(ip_address_start), ip_address_start, INET_NTOA(ip_address_end), ip_address_end, user_agent_pattern, rule, comment, site_access_rule_id" . " FROM `##site_access_rule`";
        $args = array();
        if ($search) {
            $sql .= " WHERE (INET_ATON(:search_1) BETWEEN ip_address_start AND ip_address_end" . " OR INET_NTOA(ip_address_start) LIKE CONCAT('%', :search_2, '%')" . " OR INET_NTOA(ip_address_end) LIKE CONCAT('%', :search_3, '%')" . " OR user_agent_pattern LIKE CONCAT('%', :search_4, '%')" . " OR comment LIKE CONCAT('%', :search_5, '%'))";
            $args['search_1'] = Filter::escapeLike($search);
            $args['search_2'] = Filter::escapeLike($search);
            $args['search_3'] = Filter::escapeLike($search);
            $args['search_4'] = Filter::escapeLike($search);
            $args['search_5'] = Filter::escapeLike($search);
        }
        $order = Filter::getArray('order');
        $sql .= ' ORDER BY';
        if ($order) {
            foreach ($order as $key => $value) {
                if ($key > 0) {
                    $sql .= ',';
                }
                // Datatables numbers columns 0, 1, 2, ...
                // MySQL numbers columns 1, 2, 3, ...
                switch ($value['dir']) {
                    case 'asc':
                        $sql .= " :col_" . $key . " ASC";
                        break;
                    case 'desc':
开发者ID:tunandras,项目名称:webtrees,代码行数:31,代码来源:admin_site_access.php


注:本文中的Fisharebest\Webtrees\Filter::escapeLike方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。