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


PHP Album::prepareData方法代码示例

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


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

示例1: search

function search($database, $settings, $term)
{
    if (!isset($database, $settings, $term)) {
        return false;
    }
    $return['albums'] = '';
    # Initialize return var
    $return = array('photos' => null, 'albums' => null, 'hash' => '');
    ###
    # Photos
    ###
    // Photos
    if ($database->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
        $stmtP = $database->prepare("SELECT id, title, tags, public, star, album, thumburl, takestamp, url FROM " . LYCHEE_TABLE_PHOTOS . " WHERE title LIKE ? OR description LIKE ? OR tags LIKE ?");
    } else {
        if ($database->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {
            $stmtP = $database->prepare("SELECT id, title, tags, public, star, album, thumburl, takestamp, url FROM " . LYCHEE_TABLE_PHOTOS . " WHERE title ILIKE ? OR description ILIKE ? OR tags ILIKE ?");
        } else {
            $stmtP = $database->prepare("SELECT id, title, tags, public, star, album, thumburl, takestamp, url FROM " . LYCHEE_TABLE_PHOTOS . " WHERE title LIKE ? OR description LIKE ? OR tags LIKE ?");
            Log::error($this->database, __METHOD__, __LINE__, 'Unknown database driver: ' . $database->getAttribute(PDO::ATTR_DRIVER_NAME));
        }
    }
    $result = $stmtP->execute(array('%' . $term . '%', '%' . $term . '%', '%' . $term . '%'));
    while ($photo = $stmtP->fetch(PDO::FETCH_ASSOC)) {
        $photo = Photo::prepareData($photo);
        $return['photos'][$photo['id']] = $photo;
    }
    ###
    # Albums
    ###
    if ($database->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
        $stmtA = $database->prepare("SELECT id, title, public, sysstamp, password FROM " . LYCHEE_TABLE_ALBUMS . " WHERE title LIKE ? OR description LIKE ?");
    } else {
        if ($database->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {
            $stmtA = $database->prepare("SELECT id, title, public, sysstamp, password FROM " . LYCHEE_TABLE_ALBUMS . " WHERE title ILIKE ? OR description ILIKE ?");
        } else {
            Log::error($this->database, __METHOD__, __LINE__, 'Unknown database driver: ' . $database->getAttribute(PDO::ATTR_DRIVER_NAME));
        }
    }
    $result = $stmtA->execute(array('%' . $term . '%', '%' . $term . '%'));
    while ($album = $stmtA->fetch(PDO::FETCH_ASSOC)) {
        # Turn data from the database into a front-end friendly format
        $album = Album::prepareData($album);
        // Thumbs
        $stmtT = $database->prepare("SELECT thumburl FROM " . LYCHEE_TABLE_PHOTOS . " WHERE album = ? " . $settings['sortingPhotos'] . " LIMIT 3 OFFSET 0");
        $result2 = $stmtT->execute(array($album['id']));
        $k = 0;
        while ($thumb = $stmtT->fetchObject()) {
            $album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $thumb->thumbUrl;
            $k++;
        }
        # Add to return
        $return['albums'][$album['id']] = $album;
    }
    # Hash
    $return['hash'] = md5(json_encode($return));
    return $return;
}
开发者ID:rssc,项目名称:Lychee,代码行数:58,代码来源:misc.php

示例2: get

 /**
  * @return array|false Returns an array of albums or false on failure.
  */
 public function get($public = true)
 {
     // Call plugins
     Plugins::get()->activate(__METHOD__, 0, func_get_args());
     // Initialize return var
     $return = array('smartalbums' => null, 'albums' => null, 'num' => 0);
     // Get SmartAlbums
     if ($public === false) {
         $return['smartalbums'] = $this->getSmartAlbums();
     }
     // Albums query
     if ($public === false) {
         $query = Database::prepare(Database::get(), 'SELECT id, title, public, sysstamp, password FROM ? ' . Settings::get()['sortingAlbums'], array(LYCHEE_TABLE_ALBUMS));
     } else {
         $query = Database::prepare(Database::get(), 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0 ' . Settings::get()['sortingAlbums'], array(LYCHEE_TABLE_ALBUMS));
     }
     // Execute query
     $albums = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
     if ($albums === false) {
         return false;
     }
     // For each album
     while ($album = $albums->fetch_assoc()) {
         // Turn data from the database into a front-end friendly format
         $album = Album::prepareData($album);
         // Thumbs
         if ($public === true && $album['password'] === '0' || $public === false) {
             // Execute query
             $query = Database::prepare(Database::get(), "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr(Settings::get()['sortingPhotos'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, $album['id']));
             $thumbs = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
             if ($thumbs === false) {
                 return false;
             }
             // For each thumb
             $k = 0;
             while ($thumb = $thumbs->fetch_object()) {
                 $album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $thumb->thumbUrl;
                 $k++;
             }
         }
         // Add to return
         $return['albums'][] = $album;
     }
     // Num of albums
     $return['num'] = $albums->num_rows;
     // Call plugins
     Plugins::get()->activate(__METHOD__, 1, func_get_args());
     return $return;
 }
开发者ID:windhamdavid,项目名称:Lychee,代码行数:52,代码来源:Albums.php

示例3: search

function search($settings, $term)
{
    if (!isset($settings, $term)) {
        return false;
    }
    $return['albums'] = '';
    # Initialize return var
    $return = array('photos' => null, 'albums' => null, 'hash' => '');
    ###
    # Photos
    ###
    $pterm = pg_escape_string($term);
    $sql = "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM photos WHERE title ILIKE '%" . $pterm . "%' OR description ILIKE '%" . $pterm . "%' OR tags ILIKE '%" . $pterm . "%'";
    $res = pg_query($db, $sql);
    while ($row = pg_fetch_array($res)) {
        $photo = Photo::prepareData($row);
        $return['photos'][$photo['id']] = $photo;
    }
    pg_free_result($res);
    ###
    # Albums
    ###
    $sql = "SELECT id, title, public, sysstamp, \"password\" FROM albums WHERE title ILIKE '%" . $pterm . "%' OR description ILIKE '%" . $pterm . "%'";
    $res = pg_query($db, $sql);
    while ($row = pg_fetch_array($res)) {
        # Turn data from the database into a front-end friendly format
        $album = Album::prepareData($row);
        $sql = "SELECT thumUrl FROM photos WHERE album=" . $album['id'] . " " . $settings['sortingPhotos'];
        $nres = pg_query($db, $sql);
        $k = 0;
        while ($nrow = pg_fetch_array($nres)) {
            $album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $nrow['thumbUrl'];
            $k++;
        }
        pg_free_result($nres);
        # Add to return
        $return['albums'][$album['id']] = $album;
    }
    pg_free_result($res);
    # Hash
    $return['hash'] = hash('sha256', json_encode($return), false);
    return $return;
}
开发者ID:waitman,项目名称:Lychee,代码行数:43,代码来源:misc.php

示例4: search

function search($database, $settings, $term)
{
    if (!isset($database, $settings, $term)) {
        return false;
    }
    $return['albums'] = '';
    # Initialize return var
    $return = array('photos' => null, 'albums' => null, 'hash' => '');
    ###
    # Photos
    ###
    $query = Database::prepare($database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%' OR tags LIKE '%?%'", array(LYCHEE_TABLE_PHOTOS, $term, $term, $term));
    $result = $database->query($query);
    while ($photo = $result->fetch_assoc()) {
        $photo = Photo::prepareData($photo);
        $return['photos'][$photo['id']] = $photo;
    }
    ###
    # Albums
    ###
    $query = Database::prepare($database, "SELECT id, title, public, sysstamp, password FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%'", array(LYCHEE_TABLE_ALBUMS, $term, $term));
    $result = $database->query($query);
    while ($album = $result->fetch_assoc()) {
        # Turn data from the database into a front-end friendly format
        $album = Album::prepareData($album);
        # Thumbs
        $query = Database::prepare($database, "SELECT thumbUrl FROM ? WHERE album = '?' " . $settings['sortingPhotos'] . " LIMIT 0, 3", array(LYCHEE_TABLE_PHOTOS, $album['id']));
        $thumbs = $database->query($query);
        # For each thumb
        $k = 0;
        while ($thumb = $thumbs->fetch_object()) {
            $album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $thumb->thumbUrl;
            $k++;
        }
        # Add to return
        $return['albums'][$album['id']] = $album;
    }
    # Hash
    $return['hash'] = md5(json_encode($return));
    return $return;
}
开发者ID:mattsches,项目名称:Lychee,代码行数:41,代码来源:misc.php

示例5: getAll

 public function getAll($public)
 {
     # Check dependencies
     self::dependencies(isset($this->database, $this->settings, $public));
     # Call plugins
     $this->plugins(__METHOD__, 0, func_get_args());
     # Initialize return var
     $return = array('smartalbums' => null, 'albums' => null, 'num' => 0);
     # Get SmartAlbums
     if ($public === false) {
         $return['smartalbums'] = $this->getSmartInfo();
     }
     # Albums query
     if ($public === false) {
         $albums = $this->database->query('SELECT id, title, public, sysstamp, password FROM ' . LYCHEE_TABLE_ALBUMS . ' ' . $this->settings['sortingAlbums']);
     } else {
         $albums = $this->database->query('SELECT id, title, public, sysstamp, password FROM ' . LYCHEE_TABLE_ALBUMS . ' WHERE public = 1 AND visible <> 0 ' . $this->settings['sortingAlbums']);
     }
     # check query status
     if ($albums === FALSE) {
         Log::error($this->database, __METHOD__, __LINE__, 'Could not get all albums (' . print_r($this->database->errorInfo(), TRUE) . ')');
         exit('Error: ' . print_r($this->database->errorInfo(), TRUE));
     }
     # prepare thumbnail statement
     $stmtThumbs = $this->database->prepare("SELECT thumburl FROM " . LYCHEE_TABLE_PHOTOS . " WHERE album = ? ORDER BY star DESC, " . substr($this->settings['sortingPhotos'], 9) . " LIMIT 3");
     if ($stmtThumbs === FALSE) {
         Log::error($this->database, __METHOD__, __LINE__, 'Could not get prepare statement for thumbnails (' . print_r($this->database->errorInfo(), TRUE) . ')');
         exit('Error: ' . print_r($this->database->errorInfo(), TRUE));
     }
     # For each album
     while ($album = $albums->fetch(PDO::FETCH_ASSOC)) {
         # Turn data from the database into a front-end friendly format
         $album = Album::prepareData($album);
         # Thumbs
         if ($public === true && $album['password'] === '0' || $public === false) {
             # Execute query
             $resultThumbs = $stmtThumbs->execute(array($album['id']));
             if ($resultThumbs === FALSE) {
                 Log::error($this->database, __METHOD__, __LINE__, 'Could not get thumbnails (' . print_r($this->database->errorInfo(), TRUE) . ')');
                 exit('Error: ' . print_r($this->database->errorInfo(), TRUE));
             }
             # For each thumb
             $k = 0;
             while ($thumb = $stmtThumbs->fetchObject()) {
                 $album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $thumb->thumburl;
                 $k++;
             }
         }
         # Add to return
         $return['albums'][] = $album;
     }
     # Num of albums
     $return['num'] = $albums->rowCount();
     # Call plugins
     $this->plugins(__METHOD__, 1, func_get_args());
     return $return;
 }
开发者ID:rssc,项目名称:Lychee,代码行数:57,代码来源:Album.php

示例6: getAll

 public function getAll($public)
 {
     # Check dependencies
     self::dependencies(isset($this->database, $this->settings, $public));
     # Call plugins
     $this->plugins(__METHOD__, 0, func_get_args());
     # Initialize return var
     $return = array('smartalbums' => null, 'albums' => null, 'num' => 0);
     # Get SmartAlbums
     if ($public === false) {
         $return['smartalbums'] = $this->getSmartInfo();
     }
     # Albums query
     if ($public === false) {
         $query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ? ' . $this->settings['sortingAlbums'], array(LYCHEE_TABLE_ALBUMS));
     } else {
         $query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0 ' . $this->settings['sortingAlbums'], array(LYCHEE_TABLE_ALBUMS));
     }
     # Execute query
     $albums = $this->database->query($query);
     if (!$albums) {
         Log::error($this->database, __METHOD__, __LINE__, 'Could not get all albums (' . $this->database->error . ')');
         exit('Error: ' . $this->database->error);
     }
     # For each album
     while ($album = $albums->fetch_assoc()) {
         # Turn data from the database into a front-end friendly format
         $album = Album::prepareData($album);
         # Thumbs
         if ($public === true && $album['password'] === '0' || $public === false) {
             # Execute query
             $query = Database::prepare($this->database, "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr($this->settings['sortingPhotos'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, $album['id']));
             $thumbs = $this->database->query($query);
             # For each thumb
             $k = 0;
             while ($thumb = $thumbs->fetch_object()) {
                 $album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $thumb->thumbUrl;
                 $k++;
             }
         }
         # Add to return
         $return['albums'][] = $album;
     }
     # Num of albums
     $return['num'] = $albums->num_rows;
     # Call plugins
     $this->plugins(__METHOD__, 1, func_get_args());
     return $return;
 }
开发者ID:stephen-hill,项目名称:Lychee,代码行数:49,代码来源:Album.php

示例7: getAll

 public function getAll($public)
 {
     # Check dependencies
     self::dependencies(isset($this->settings, $public));
     # Initialize return var
     $return = array('smartalbums' => null, 'albums' => null, 'num' => 0);
     # Get SmartAlbums
     if ($public === false) {
         $return['smartalbums'] = $this->getSmartInfo();
     }
     # Albums query
     if ($public === false) {
         $sql = "SELECT id, title, public, sysstamp, password FROM albums " . $this->settings['sortingAlbums'];
     } else {
         $sql = "SELECT id, title, public, sysstamp, password FROM albums WHERE public = 1 AND visible != 0 " . $this->settings['sortingAlbums'];
     }
     # Execute query
     $res = pg_query($db, $sql);
     # For each album
     while ($row = pg_fetch_array($res)) {
         # Turn data from the database into a front-end friendly format
         $album = Album::prepareData($row);
         # Thumbs
         if ($public === true && $album['password'] === '0' || $public === false) {
             # Execute query
             $sql = "SELECT thumbUrl FROM photos WHERE album = " . intval($album['id']) . " ORDER BY star DESC, " . substr($this->settings['sortingPhotos'], 9);
             $nres = pg_query($db, $sql);
             # For each thumb
             $k = 0;
             while ($nrow = pg_fetch_array($nres)) {
                 $album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $nrow['thumbUrl'];
                 $k++;
             }
             pg_free_result($nres);
         }
         # Add to return
         $return['albums'][] = $album;
     }
     # Num of albums
     $return['num'] = pg_num_rows($res);
     pg_free_result($res);
     return $return;
 }
开发者ID:waitman,项目名称:Lychee,代码行数:43,代码来源:Album.php


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