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


PHP db_LIKE_escape函数代码示例

本文整理汇总了PHP中db_LIKE_escape函数的典型用法代码示例。如果您正苦于以下问题:PHP db_LIKE_escape函数的具体用法?PHP db_LIKE_escape怎么用?PHP db_LIKE_escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: garbageCollect

 /**
  * For every image in the album, look for its file. Delete from the database
  * if the file does not exist. Same for each sub-directory/album.
  *
  * @param bool $deep set to true for a thorough cleansing
  */
 function garbageCollect($deep = false)
 {
     if (is_null($this->images)) {
         $this->getImages();
     }
     $result = query("SELECT * FROM " . prefix('images') . " WHERE `albumid` = '" . $this->id . "'");
     $dead = array();
     $live = array();
     $files = $this->loadFileNames();
     // Does the filename from the db row match any in the files on disk?
     while ($row = db_fetch_assoc($result)) {
         if (!in_array($row['filename'], $files)) {
             // In the database but not on disk. Kill it.
             $dead[] = $row['id'];
         } else {
             if (in_array($row['filename'], $live)) {
                 // Duplicate in the database. Kill it.
                 $dead[] = $row['id'];
                 // Do something else here? Compare titles/descriptions/metadata/update dates to see which is the latest?
             } else {
                 $live[] = $row['filename'];
             }
         }
     }
     db_free_result($result);
     if (count($dead) > 0) {
         $sql = "DELETE FROM " . prefix('images') . " WHERE `id` = '" . array_pop($dead) . "'";
         $sql2 = "DELETE FROM " . prefix('comments') . " WHERE `type`='albums' AND `ownerid` = '" . array_pop($dead) . "'";
         foreach ($dead as $id) {
             $sql .= " OR `id` = '{$id}'";
             $sql2 .= " OR `ownerid` = '{$id}'";
         }
         query($sql);
         query($sql2);
     }
     // Get all sub-albums and make sure they exist.
     $result = query("SELECT * FROM " . prefix('albums') . " WHERE `folder` LIKE " . db_quote(db_LIKE_escape($this->name) . '%'));
     $dead = array();
     $live = array();
     // Does the dirname from the db row exist on disk?
     while ($row = db_fetch_assoc($result)) {
         if (!is_dir(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($row['folder'])) || in_array($row['folder'], $live) || substr($row['folder'], -1) == '/' || substr($row['folder'], 0, 1) == '/') {
             $dead[] = $row['id'];
         } else {
             $live[] = $row['folder'];
         }
     }
     db_free_result($result);
     if (count($dead) > 0) {
         $sql = "DELETE FROM " . prefix('albums') . " WHERE `id` = '" . array_pop($dead) . "'";
         $sql2 = "DELETE FROM " . prefix('comments') . " WHERE `type`='albums' AND `ownerid` = '" . array_pop($dead) . "'";
         foreach ($dead as $albumid) {
             $sql .= " OR `id` = '{$albumid}'";
             $sql2 .= " OR `ownerid` = '{$albumid}'";
         }
         query($sql);
         query($sql2);
     }
     if ($deep) {
         foreach ($this->getAlbums(0) as $dir) {
             $subalbum = newAlbum($dir);
             // Could have been deleted if it didn't exist above...
             if ($subalbum->exists) {
                 $subalbum->garbageCollect($deep);
             }
         }
     }
 }
开发者ID:JoniWeiss,项目名称:JoniWebGirl,代码行数:74,代码来源:class-album.php

示例2: getAllSubAlbumIDs

/**
 * Returns  an array of album ids whose parent is the folder
 * @param string $albumfolder folder name if you want a album different >>from the current album
 * @return array
 */
function getAllSubAlbumIDs($albumfolder = '')
{
    global $_zp_current_album;
    if (empty($albumfolder)) {
        if (isset($_zp_current_album)) {
            $albumfolder = $_zp_current_album->getFileName();
        } else {
            return null;
        }
    }
    $query = "SELECT `id`,`folder`, `show` FROM " . prefix('albums') . " WHERE `folder` LIKE " . db_quote(db_LIKE_escape($albumfolder) . '%');
    $subIDs = query_full_array($query);
    return $subIDs;
}
开发者ID:JoniWeiss,项目名称:JoniWebGirl,代码行数:19,代码来源:functions.php

示例3: getAlbumInherited

/**
 * returns the non-empty value of $field from the album or one of its parents
 *
 * @param string $folder the album name
 * @param string $field the desired field name
 * @param int $id will be set to the album `id` of the album which has the non-empty field
 * @return string
 */
function getAlbumInherited($folder, $field, &$id)
{
    $folders = explode('/', filesystemToInternal($folder));
    $album = array_shift($folders);
    $like = ' LIKE ' . db_quote(db_LIKE_escape($album));
    while (count($folders) > 0) {
        $album .= '/' . array_shift($folders);
        $like .= ' OR `folder` LIKE ' . db_quote(db_LIKE_escape($album));
    }
    $sql = 'SELECT `id`, `' . $field . '` FROM ' . prefix('albums') . ' WHERE `folder`' . $like;
    $result = query_full_array($sql);
    if (!is_array($result)) {
        return '';
    }
    while (count($result) > 0) {
        $try = array_pop($result);
        if (!empty($try[$field])) {
            $id = $try['id'];
            return $try[$field];
        }
    }
    return '';
}
开发者ID:rb26,项目名称:zenphoto,代码行数:31,代码来源:functions-basic.php

示例4: getRandomImagesAlbum

/**
 * Returns  a randomly selected image from the album or its subalbums. (May be NULL if none exists)
 *
 * @param mixed $rootAlbum optional album object/folder from which to get the image.
 * @param bool $daily set to true to change picture only once a day.
 *
 * @return object
 */
function getRandomImagesAlbum($rootAlbum = NULL, $daily = false)
{
    global $_zp_current_album, $_zp_gallery, $_zp_current_search;
    if (empty($rootAlbum)) {
        $album = $_zp_current_album;
    } else {
        if (is_object($rootAlbum)) {
            $album = $rootAlbum;
        } else {
            $album = newAlbum($rootAlbum);
        }
    }
    if ($daily && ($potd = getOption('picture_of_the_day:' . $album->name))) {
        $potd = getSerializedArray($potd);
        if (date('Y-m-d', $potd['day']) == date('Y-m-d')) {
            $rndalbum = newAlbum($potd['folder']);
            $image = newImage($rndalbum, $potd['filename']);
            if ($image->exists) {
                return $image;
            }
        }
    }
    $image = NULL;
    if ($album->isDynamic()) {
        $images = $album->getImages(0);
        shuffle($images);
        while (count($images) > 0) {
            $result = array_pop($images);
            if (Gallery::validImage($result['filename'])) {
                $image = newImage(newAlbum($result['folder']), $result['filename']);
            }
        }
    } else {
        $albumfolder = $album->getFileName();
        if ($album->isMyItem(LIST_RIGHTS)) {
            $imageWhere = '';
            $albumInWhere = '';
        } else {
            $imageWhere = " AND " . prefix('images') . ".show=1";
            $albumInWhere = prefix('albums') . ".show=1";
        }
        $query = "SELECT id FROM " . prefix('albums') . " WHERE ";
        if ($albumInWhere) {
            $query .= $albumInWhere . ' AND ';
        }
        $query .= "folder LIKE " . db_quote(db_LIKE_escape($albumfolder) . '%');
        $result = query($query);
        if ($result) {
            $albumInWhere = prefix('albums') . ".id IN (";
            while ($row = db_fetch_assoc($result)) {
                $albumInWhere = $albumInWhere . $row['id'] . ", ";
            }
            db_free_result($result);
            $albumInWhere = ' AND ' . substr($albumInWhere, 0, -2) . ')';
            $sql = 'SELECT `folder`, `filename` ' . ' FROM ' . prefix('images') . ', ' . prefix('albums') . ' WHERE ' . prefix('albums') . '.folder!="" AND ' . prefix('images') . '.albumid = ' . prefix('albums') . '.id ' . $albumInWhere . $imageWhere . ' ORDER BY RAND()';
            $result = query($sql);
            $image = filterImageQuery($result, $album->name);
        }
    }
    if ($image) {
        if ($daily) {
            $potd = array('day' => time(), 'folder' => $image->getAlbumName(), 'filename' => $image->getFileName());
            setThemeOption('picture_of_the_day:' . $album->name, serialize($potd), NULL, $_zp_gallery->getCurrentTheme());
        }
    }
    return $image;
}
开发者ID:IliyanGochev,项目名称:zenphoto,代码行数:75,代码来源:template-functions.php

示例5: db_show

function db_show($what, $aux = '')
{
    global $_zp_DB_details;
    switch ($what) {
        case 'tables':
            $sql = "SHOW TABLES FROM `" . $_zp_DB_details['mysql_database'] . "` LIKE '" . db_LIKE_escape($_zp_DB_details['mysql_prefix']) . "%'";
            return query($sql, false);
        case 'columns':
            $sql = 'SHOW FULL COLUMNS FROM `' . $_zp_DB_details['mysql_prefix'] . $aux . '`';
            return query($sql, true);
        case 'variables':
            $sql = "SHOW VARIABLES LIKE '{$aux}'";
            return query_full_array($sql);
        case 'index':
            $sql = "SHOW INDEX FROM `" . $_zp_DB_details['mysql_database'] . '`.' . $aux;
            return query_full_array($sql);
    }
}
开发者ID:JoniWeiss,项目名称:JoniWebGirl,代码行数:18,代码来源:functions-db-MySQLi.php

示例6: getAllTagsFromAlbum

/**
 * Prints a tag cloud list of the tags in one album and optionally its subalbums. Returns FALSE if no value.
 *
 * @param string $albumname folder name of the album to get the tags from ($subalbums = true this is the base albums)- This value is mandatory.
 * @param bool $subalbums TRUE if the tags of subalbum should be. FALSE is default
 * @param string $mode "images" for image tags, "albums" for album tags."images" is default.
 * @return array
 */
function getAllTagsFromAlbum($albumname, $subalbums = false, $mode = 'images')
{
    global $_zp_gallery;
    $passwordcheck = '';
    $imageWhere = '';
    $tagWhere = "";
    if (empty($albumname)) {
        return FALSE;
    }
    $albumobj = newAlbum($albumname);
    if (!$albumobj->exists) {
        return FALSE;
    }
    if (zp_loggedin()) {
        $albumWhere = "WHERE `dynamic`=0";
    } else {
        $albumscheck = query_full_array("SELECT * FROM " . prefix('albums') . " ORDER BY title");
        foreach ($albumscheck as $albumcheck) {
            if (!checkAlbumPassword($albumcheck['folder'])) {
                $albumpasswordcheck = " AND id != " . $albumcheck['id'];
                $passwordcheck = $passwordcheck . $albumpasswordcheck;
            }
        }
        $albumWhere = "WHERE `dynamic`=0 AND `show`=1" . $passwordcheck;
    }
    if ($subalbums) {
        $albumWhere .= " AND `folder` LIKE " . db_quote(db_LIKE_escape($albumname) . "%");
    } else {
        $albumWhere .= " AND `folder` = " . db_quote($albumname);
    }
    $albumids = query_full_array("SELECT id, folder FROM " . prefix('albums') . $albumWhere);
    switch ($mode) {
        case "images":
            if (count($albumids) == 0) {
                return FALSE;
            } else {
                $imageWhere = " WHERE ";
                $count = "";
                foreach ($albumids as $albumid) {
                    $count++;
                    $imageWhere .= 'albumid=' . $albumid['id'];
                    if ($count != count($albumids)) {
                        $imageWhere .= " OR ";
                    }
                }
            }
            $imageids = query_full_array("SELECT id, albumid FROM " . prefix('images') . $imageWhere);
            // if the album has no direct images and $subalbums is set to false
            if (count($imageids) == 0) {
                return FALSE;
            } else {
                $count = "";
                $tagWhere = " WHERE ";
                foreach ($imageids as $imageid) {
                    $count++;
                    $tagWhere .= '(o.objectid =' . $imageid['id'] . " AND o.tagid = t.id AND o.type = 'images')";
                    if ($count != count($imageids)) {
                        $tagWhere .= " OR ";
                    }
                }
            }
            if (empty($tagWhere)) {
                return FALSE;
            } else {
                $tags = query_full_array("SELECT DISTINCT t.name, t.id, (SELECT DISTINCT COUNT(*) FROM " . prefix('obj_to_tag') . " WHERE tagid = t.id AND type = 'images') AS count FROM  " . prefix('obj_to_tag') . " AS o," . prefix('tags') . " AS t" . $tagWhere . " ORDER BY t.name");
            }
            break;
        case "albums":
            $count = "";
            if (count($albumids) == 0) {
                return FALSE;
            } else {
                $tagWhere = " WHERE ";
                foreach ($albumids as $albumid) {
                    $count++;
                    $tagWhere .= '(o.objectid =' . $albumid['id'] . " AND o.tagid = t.id AND o.type = 'albums')";
                    if ($count != count($albumids)) {
                        $tagWhere .= " OR ";
                    }
                }
            }
            if (empty($tagWhere)) {
                return FALSE;
            } else {
                $tags = query_full_array("SELECT DISTINCT t.name, t.id, (SELECT DISTINCT COUNT(*) FROM " . prefix('obj_to_tag') . " WHERE tagid = t.id AND o.type = 'albums') AS count FROM " . prefix('obj_to_tag') . " AS o," . prefix('tags') . " AS t" . $tagWhere . " ORDER BY t.name");
            }
            break;
    }
    return $tags;
}
开发者ID:ariep,项目名称:ZenPhoto20-DEV,代码行数:98,代码来源:tag_extras.php

示例7: readTags

/**
 * Retrieves the tags for an object
 * Returns them in an array
 *
 * @param int $id the record id of the album/image
 * @param string $tbl 'albums' or 'images', etc.
 * @return array
 */
function readTags($id, $tbl, $language)
{
    global $_zp_current_locale;
    if (is_null($language)) {
        switch (getOption('languageTagSearch')) {
            case 1:
                $language = substr($_zp_current_locale, 0, 2);
                break;
            case 2:
                $language = $_zp_current_locale;
                break;
            default:
                $langage = '';
                break;
        }
    }
    $tags = array();
    $sql = 'SELECT * FROM ' . prefix('tags') . ' AS tags, ' . prefix('obj_to_tag') . ' AS objects WHERE `type`="' . $tbl . '" AND `objectid`="' . $id . '" AND tagid=tags.id';
    if ($language) {
        $sql .= ' AND (tags.language="" OR tags.language LIKE ' . db_quote(db_LIKE_escape($language) . '%') . ')';
    }
    $result = query($sql);
    if ($result) {
        while ($row = db_fetch_assoc($result)) {
            $tags[mb_strtolower($row['name'])] = $row['name'];
        }
        db_free_result($result);
    }
    natcasesort($tags);
    return $tags;
}
开发者ID:ariep,项目名称:ZenPhoto20-DEV,代码行数:39,代码来源:functions.php

示例8: searchFieldsAndTags

 /**
  * Searches the table for tags
  * Returns an array of database records.
  *
  * @param array $searchstring
  * @param string $tbl set DB table name to be searched
  * @param string $sorttype what to sort on
  * @param string $sortdirection what direction
  * @return array
  */
 protected function searchFieldsAndTags($searchstring, $tbl, $sorttype, $sortdirection)
 {
     global $_zp_gallery;
     $weights = $idlist = array();
     $sql = $allIDs = NULL;
     $tagPattern = $this->tagPattern;
     // create an array of [tag, objectid] pairs for tags
     $tag_objects = array();
     $fields = $this->fieldList;
     if (count($fields) == 0) {
         // then use the default ones
         $fields = $this->allowedSearchFields();
     }
     foreach ($fields as $key => $field) {
         switch ($field) {
             case 'news_categories':
                 if ($tbl != 'news') {
                     break;
                 }
                 unset($fields[$key]);
                 query('SET @serachfield="news_categories"');
                 $tagsql = 'SELECT @serachfield AS field, t.`title` AS name, o.`news_id` AS `objectid` FROM ' . prefix('news_categories') . ' AS t, ' . prefix('news2cat') . ' AS o WHERE t.`id`=o.`cat_id` AND (';
                 foreach ($searchstring as $singlesearchstring) {
                     switch ($singlesearchstring) {
                         case '&':
                         case '!':
                         case '|':
                         case '(':
                         case ')':
                             break;
                         case '*':
                             $targetfound = true;
                             $tagsql .= "COALESCE(title, '') != '' OR ";
                             break;
                         default:
                             $targetfound = true;
                             $tagsql .= '`title` = ' . db_quote($singlesearchstring) . ' OR ';
                     }
                 }
                 $tagsql = substr($tagsql, 0, strlen($tagsql) - 4) . ') ORDER BY t.`id`';
                 $objects = query_full_array($tagsql, false);
                 if (is_array($objects)) {
                     $tag_objects = $objects;
                 }
                 break;
             case 'tags_exact':
                 $tagPattern = array('type' => '=', 'open' => '', 'close' => '');
             case 'tags':
                 unset($fields[$key]);
                 query('SET @serachfield="tags"');
                 $tagsql = 'SELECT @serachfield AS field, t.`name`, o.`objectid` FROM ' . prefix('tags') . ' AS t, ' . prefix('obj_to_tag') . ' AS o WHERE t.`id`=o.`tagid` AND o.`type`="' . $tbl . '" AND (';
                 foreach ($searchstring as $singlesearchstring) {
                     switch ($singlesearchstring) {
                         case '&':
                         case '!':
                         case '|':
                         case '(':
                         case ')':
                             break;
                         case '*':
                             query('SET @emptyfield="*"');
                             $tagsql = str_replace('t.`name`', '@emptyfield as name', $tagsql);
                             $tagsql .= "t.`name` IS NOT NULL OR ";
                             break;
                         default:
                             $targetfound = true;
                             if ($tagPattern['type'] == 'like') {
                                 $target = db_LIKE_escape($singlesearchstring);
                             } else {
                                 $target = $singlesearchstring;
                             }
                             $tagsql .= 't.`name` ' . strtoupper($tagPattern['type']) . ' ' . db_quote($tagPattern['open'] . $target . $tagPattern['close']) . ' OR ';
                     }
                 }
                 $tagsql = substr($tagsql, 0, strlen($tagsql) - 4) . ') ORDER BY t.`id`';
                 $objects = query_full_array($tagsql, false);
                 if (is_array($objects)) {
                     $tag_objects = array_merge($tag_objects, $objects);
                 }
                 break;
             default:
                 break;
         }
     }
     // create an array of [name, objectid] pairs for the search fields.
     $field_objects = array();
     if (count($fields) > 0) {
         $columns = array();
         $dbfields = db_list_fields($tbl);
         if (is_array($dbfields)) {
//.........这里部分代码省略.........
开发者ID:elpadi,项目名称:dahlen-studio,代码行数:101,代码来源:class-search.php


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