本文整理汇总了PHP中WT_Filter::escapeLike方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_Filter::escapeLike方法的具体用法?PHP WT_Filter::escapeLike怎么用?PHP WT_Filter::escapeLike使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_Filter
的用法示例。
在下文中一共展示了WT_Filter::escapeLike方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
*
* @return WT_Media[]
* @throws Exception
*/
public static function mediaList($folder, $subfolders, $sort, $filter)
{
// All files in the folder, plus external files
$sql = "SELECT m_id AS xref, m_file AS gedcom_id, m_gedcom AS gedcom" . " FROM `##media`" . " WHERE m_file=?";
$args = array(WT_GED_ID);
// 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[] = WT_Filter::escapeLike($folder);
break;
case 'exclude':
$sql .= " AND (m_filename LIKE CONCAT(?, '%') AND m_filename NOT LIKE CONCAT(?, '%/%') {$sql_external})";
$args[] = WT_Filter::escapeLike($folder);
$args[] = WT_Filter::escapeLike($folder);
break;
default:
throw new Exception('Bad argument (subfolders=' . $subfolders . ') in WT_Query_Media::mediaList()');
}
// Apply search terms
if ($filter) {
$sql .= " AND (SUBSTRING_INDEX(m_filename, '/', -1) LIKE CONCAT('%', ?, '%') OR m_titl LIKE CONCAT('%', ?, '%'))";
$args[] = WT_Filter::escapeLike($filter);
$args[] = WT_Filter::escapeLike($filter);
}
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 WT_Query_Media::mediaList()');
}
$rows = WT_DB::prepare($sql)->execute($args)->fetchAll();
$list = array();
foreach ($rows as $row) {
$media = WT_Media::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
if ($media->canShow()) {
$list[] = $media;
}
}
return $list;
}
示例2: all_media_files
function all_media_files($media_folder, $media_path, $subfolders, $filter)
{
return WT_DB::prepare("SELECT SQL_CACHE SQL_CALC_FOUND_ROWS TRIM(LEADING ? 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=?" . " AND m_filename LIKE CONCAT(?, '%')" . " AND (SUBSTRING_INDEX(m_filename, '/', -1) LIKE CONCAT('%', ?, '%')" . " OR m_titl LIKE CONCAT('%', ?, '%'))" . "\tAND m_filename NOT LIKE 'http://%'" . " AND m_filename NOT LIKE 'https://%'")->execute(array($media_path, $media_folder, WT_Filter::escapeLike($media_path), WT_Filter::escapeLike($filter), WT_Filter::escapeLike($filter)))->fetchOneColumn();
}