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


PHP Dba::read方法代码示例

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


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

示例1: getRecords

 private function getRecords($table, $field = null, $value = null)
 {
     $data = array();
     $sql = $this->assembleQuery($table, $field);
     $statement = \Dba::read($sql, is_array($value) ? $value : array($value));
     while ($object = \Dba::fetch_object($statement, $this->modelClassName)) {
         $data[$object->getId()] = $object;
     }
     return $data;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:10,代码来源:Repository.php

示例2: build_cache

 /**
  * build_cache
  * Build a cache based on the array of ids passed, saves lots of little queries
  */
 public static function build_cache($ids = array())
 {
     if (!is_array($ids) or !count($ids)) {
         return false;
     }
     $idlist = '(' . implode(',', $ids) . ')';
     $sql = "SELECT * FROM `video` WHERE `video`.`id` IN {$idlist}";
     $db_results = Dba::read($sql);
     while ($row = Dba::fetch_assoc($db_results)) {
         parent::add_to_cache('video', $row['id'], $row);
     }
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:16,代码来源:video.class.php

示例3: update_preferences

function update_preferences($pref_id = 0)
{
    /* Get current keys */
    $sql = "SELECT `id`,`name`,`type` FROM `preference`";
    /* If it isn't the System Account's preferences */
    if ($pref_id != '-1') {
        $sql .= " WHERE `catagory` != 'system'";
    }
    $db_results = Dba::read($sql);
    $results = array();
    // Collect the current possible keys
    while ($r = Dba::fetch_assoc($db_results)) {
        $results[] = array('id' => $r['id'], 'name' => $r['name'], 'type' => $r['type']);
    }
    // end collecting keys
    /* Foreach through possible keys and assign them */
    foreach ($results as $data) {
        /* Get the Value from POST/GET var called $data */
        $name = $data['name'];
        $apply_to_all = 'check_' . $data['name'];
        $new_level = 'level_' . $data['name'];
        $id = $data['id'];
        $value = scrub_in($_REQUEST[$name]);
        /* Some preferences require some extra checks to be performed */
        switch ($name) {
            case 'transcode_bitrate':
                $value = Stream::validate_bitrate($value);
                break;
            default:
                break;
        }
        if (preg_match('/_pass$/', $name)) {
            if ($value == '******') {
                unset($_REQUEST[$name]);
            } else {
                if (preg_match('/md5_pass$/', $name)) {
                    $value = md5($value);
                }
            }
        }
        /* Run the update for this preference only if it's set */
        if (isset($_REQUEST[$name])) {
            Preference::update($id, $pref_id, $value, $_REQUEST[$apply_to_all]);
        }
        if (Access::check('interface', '100') && $_REQUEST[$new_level]) {
            Preference::update_level($id, $_REQUEST[$new_level]);
        }
    }
    // end foreach preferences
    // Now that we've done that we need to invalidate the cached preverences
    Preference::clear_from_session();
}
开发者ID:cheese1,项目名称:ampache,代码行数:52,代码来源:preferences.php

示例4: get_info

 /**
  * get_info
  * retrieves the info from the database and puts it in the cache
  */
 public function get_info($id, $table_name = '')
 {
     $table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));
     // Make sure we've got a real id
     if (!is_numeric($id)) {
         return array();
     }
     if (self::is_cached($table_name, $id)) {
         return self::get_from_cache($table_name, $id);
     }
     $sql = "SELECT * FROM `{$table_name}` WHERE `id`='{$id}'";
     $db_results = Dba::read($sql);
     if (!$db_results) {
         return array();
     }
     $row = Dba::fetch_assoc($db_results);
     self::add_to_cache($table_name, $id, $row);
     return $row;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:23,代码来源:database_object.abstract.php

示例5: __construct

 /**
  * Stream_Playlist constructor
  * If an ID is passed, it should be a stream session ID.
  */
 public function __construct($id = null)
 {
     if ($id != -1) {
         if ($id) {
             Stream::set_session($id);
         }
         $this->id = Stream::$session;
         if (!Session::exists('stream', $this->id)) {
             debug_event('stream_playlist', 'Session::exists failed', 2);
             return false;
         }
         $this->user = intval($GLOBALS['user']->id);
         $sql = 'SELECT * FROM `stream_playlist` WHERE `sid` = ? ORDER BY `id`';
         $db_results = Dba::read($sql, array($this->id));
         while ($row = Dba::fetch_assoc($db_results)) {
             $this->urls[] = new Stream_URL($row);
         }
     }
     return true;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:24,代码来源:stream_playlist.class.php

示例6: show_playlist_select

/**
 * show_playlist_select
 * This one is for playlists!
 */
function show_playlist_select($name, $selected = '', $style = '')
{
    echo "<select name=\"{$name}\" style=\"{$style}\">\n";
    echo "\t<option value=\"\">" . T_('None') . "</option>\n";
    $sql = "SELECT `id`,`name` FROM `playlist` ORDER BY `name`";
    $db_results = Dba::read($sql);
    $nb_items = Dba::num_rows($db_results);
    $index = 1;
    $already_selected = false;
    while ($row = Dba::fetch_assoc($db_results)) {
        $select_txt = '';
        if (!$already_selected && ($row['id'] == $selected || $index == $nb_items)) {
            $select_txt = 'selected="selected"';
            $already_selected = true;
        }
        echo "\t<option value=\"" . $row['id'] . "\" {$select_txt}>" . scrub_out($row['name']) . "</option>\n";
        ++$index;
    }
    // end while users
    echo "</select>\n";
}
开发者ID:cheese1,项目名称:ampache,代码行数:25,代码来源:ui.lib.php

示例7: get

 /**
  * get_songs
  * This functions returns an array containing information about
  * the songs that MPD currently has in its playlist. This must be
  * done in a standardized fashion
  */
 public function get()
 {
     // If we don't have the playlist yet, pull it
     if (!isset($this->_mpd->playlist)) {
         $this->_mpd->RefreshInfo();
     }
     /* Get the Current Playlist */
     $playlist = $this->_mpd->playlist;
     foreach ($playlist as $entry) {
         $data = array();
         /* Required Elements */
         $data['id'] = $entry['Pos'];
         $data['raw'] = $entry['file'];
         $url_data = $this->parse_url($entry['file']);
         switch ($url_data['primary_key']) {
             case 'oid':
                 $data['oid'] = $url_data['oid'];
                 $song = new Song($data['oid']);
                 $song->format();
                 $data['name'] = $song->f_title . ' - ' . $song->f_album . ' - ' . $song->f_artist;
                 $data['link'] = $song->f_link;
                 break;
             case 'demo_id':
                 $democratic = new Democratic($url_data['demo_id']);
                 $data['name'] = T_('Democratic') . ' - ' . $democratic->name;
                 $data['link'] = '';
                 break;
             case 'random':
                 $data['name'] = T_('Random') . ' - ' . scrub_out(ucfirst($url_data['type']));
                 $data['link'] = '';
                 break;
             default:
                 /* If we don't know it, look up by filename */
                 $filename = Dba::escape($entry['file']);
                 $sql = "SELECT `id`,'song' AS `type` FROM `song` WHERE `file` LIKE '%{$filename}' " . "UNION ALL " . "SELECT `id`,'live_stream' AS `type` FROM `live_stream` WHERE `url`='{$filename}' ";
                 $db_results = Dba::read($sql);
                 if ($row = Dba::fetch_assoc($db_results)) {
                     $media = new $row['type']($row['id']);
                     $media->format();
                     switch ($row['type']) {
                         case 'song':
                             $data['name'] = $media->f_title . ' - ' . $media->f_album . ' - ' . $media->f_artist;
                             $data['link'] = $media->f_link;
                             break;
                         case 'live_stream':
                             $frequency = $media->frequency ? '[' . $media->frequency . ']' : '';
                             $site_url = $media->site_url ? '(' . $media->site_url . ')' : '';
                             $data['name'] = "{$media->name} {$frequency} {$site_url}";
                             $data['link'] = $media->site_url;
                             break;
                     }
                     // end switch on type
                 } else {
                     $data['name'] = T_('Unknown');
                     $data['link'] = '';
                 }
                 break;
         }
         // end switch on primary key type
         /* Optional Elements */
         $data['track'] = $entry['Pos'] + 1;
         $results[] = $data;
     }
     // foreach playlist items
     return $results;
 }
开发者ID:nioc,项目名称:ampache,代码行数:72,代码来源:mpd.controller.php

示例8: get_song_previews

 public static function get_song_previews($album_mbid)
 {
     $songs = array();
     $sql = "SELECT `id` FROM `song_preview` " . "WHERE `session` = ? AND `album_mbid` = ?";
     $db_results = Dba::read($sql, array(session_id(), $album_mbid));
     while ($results = Dba::fetch_assoc($db_results)) {
         $songs[] = new Song_Preview($results['id']);
     }
     return $songs;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:10,代码来源:song_preview.class.php

示例9: get_highest

 /**
  * get_highest
  * Get objects with the highest average rating.
  */
 public static function get_highest($type, $count = '', $offset = '')
 {
     if (!$count) {
         $count = AmpConfig::get('popular_threshold');
     }
     $count = intval($count);
     if (!$offset) {
         $limit = $count;
     } else {
         $limit = intval($offset) . "," . $count;
     }
     /* Select Top objects counting by # of rows */
     $sql = self::get_highest_sql($type);
     $sql .= "LIMIT {$limit}";
     $db_results = Dba::read($sql, array($type));
     $results = array();
     while ($row = Dba::fetch_assoc($db_results)) {
         $results[] = $row['id'];
     }
     return $results;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:25,代码来源:rating.class.php

示例10: update_370028

 /**
  * update_370028
  *
  * Add width and height in table image
  *
  */
 public static function update_370028()
 {
     $retval = true;
     $sql = "select `width` from `image`";
     $db_results = Dba::read($sql);
     if (!$db_results) {
         $sql = "ALTER TABLE `image` ADD `width` int(4) unsigned DEFAULT 0 AFTER `image`";
         $retval &= Dba::write($sql);
     }
     $sql = "select `height` from `image`";
     $db_results = Dba::read($sql);
     if (!$db_results) {
         $sql = "ALTER TABLE `image` ADD `height` int(4) unsigned DEFAULT 0 AFTER `width`";
         $retval &= Dba::write($sql);
     }
     return $retval;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:23,代码来源:update.class.php

示例11: get

 /**
  * get
  * This functions returns an array containing information about
  * The songs that vlc currently has in it's playlist. This must be
  * done in a standardized fashion
  * Warning ! if you got files in vlc medialibary those files will be sent to the php xml parser
  * to, not to your browser but still this can take a lot of work for your server.
  * The xml files of vlc need work, not much documentation on them....
  */
 public function get()
 {
     /* Get the Current Playlist */
     $list = $this->_vlc->get_tracks();
     if (!$list) {
         return array();
     }
     $counterforarray = 0;
     // here we look if there are song in the playlist when media libary is used
     if ($list['node']['node'][0]['leaf'][$counterforarray]['attr']['uri']) {
         while ($list['node']['node'][0]['leaf'][$counterforarray]) {
             $songs[] = htmlspecialchars_decode($list['node']['node'][0]['leaf'][$counterforarray]['attr']['uri'], ENT_NOQUOTES);
             $songid[] = $list['node']['node'][0]['leaf'][$counterforarray]['attr']['id'];
             $counterforarray++;
         }
         // if there is only one song look here,and media libary is used
     } elseif ($list['node']['node'][0]['leaf']['attr']['uri']) {
         $songs[] = htmlspecialchars_decode($list['node']['node'][0]['leaf']['attr']['uri'], ENT_NOQUOTES);
         $songid[] = $list['node']['node'][0]['leaf']['attr']['id'];
     } elseif ($list['node']['node']['leaf'][$counterforarray]['attr']['uri']) {
         while ($list['node']['node']['leaf'][$counterforarray]) {
             $songs[] = htmlspecialchars_decode($list['node']['node']['leaf'][$counterforarray]['attr']['uri'], ENT_NOQUOTES);
             $songid[] = $list['node']['node']['leaf'][$counterforarray]['attr']['id'];
             $counterforarray++;
         }
     } elseif ($list['node']['node']['leaf']['attr']['uri']) {
         $songs[] = htmlspecialchars_decode($list['node']['node']['leaf']['attr']['uri'], ENT_NOQUOTES);
         $songid[] = $list['node']['node']['leaf']['attr']['id'];
     } else {
         return array();
     }
     $counterforarray = 0;
     foreach ($songs as $key => $entry) {
         $data = array();
         /* Required Elements */
         $data['id'] = $songid[$counterforarray];
         // id number of the files in the vlc playlist, needed for other operations
         $data['raw'] = $entry;
         $url_data = $this->parse_url($entry);
         switch ($url_data['primary_key']) {
             case 'oid':
                 $data['oid'] = $url_data['oid'];
                 $song = new Song($data['oid']);
                 $song->format();
                 $data['name'] = $song->f_title . ' - ' . $song->f_album . ' - ' . $song->f_artist;
                 $data['link'] = $song->f_link;
                 break;
             case 'demo_id':
                 $democratic = new Democratic($url_data['demo_id']);
                 $data['name'] = T_('Democratic') . ' - ' . $democratic->name;
                 $data['link'] = '';
                 break;
             case 'random':
                 $data['name'] = T_('Random') . ' - ' . scrub_out(ucfirst($url_data['type']));
                 $data['link'] = '';
                 break;
             default:
                 /* If we don't know it, look up by filename */
                 $filename = Dba::escape($entry);
                 $sql = "SELECT `name` FROM `live_stream` WHERE `url`='{$filename}' ";
                 $db_results = Dba::read($sql);
                 if ($row = Dba::fetch_assoc($db_results)) {
                     //if stream is known just send name
                     $data['name'] = htmlspecialchars(substr($row['name'], 0, 50));
                 } elseif (strncmp($entry, 'http', 4) == 0) {
                     $data['name'] = htmlspecialchars("(VLC stream) " . substr($entry, 0, 50));
                 } else {
                     $getlast = explode("/", $entry);
                     $lastis = count($getlast) - 1;
                     $data['name'] = htmlspecialchars("(VLC local) " . substr($getlast[$lastis], 0, 50));
                 }
                 // end if loop
                 break;
         }
         // end switch on primary key type
         $data['track'] = $key + 1;
         $counterforarray++;
         $results[] = $data;
     }
     // foreach playlist items
     return $results;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:91,代码来源:vlc.controller.php

示例12: check_lock_media

 /**
  * check_lock_media
  *
  * This checks to see if the media is already being played.
  */
 public static function check_lock_media($media_id, $type)
 {
     $sql = 'SELECT `object_id` FROM `now_playing` WHERE ' . '`object_id` = ? AND `object_type` = ?';
     $db_results = Dba::read($sql, array($media_id, $type));
     if (Dba::num_rows($db_results)) {
         debug_event('Stream', 'Unable to play media currently locked by another user', 3);
         return false;
     }
     return true;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:15,代码来源:stream.class.php

示例13: get_shares

 public static function get_shares($object_type, $object_id)
 {
     $sql = "SELECT `id` FROM `share` WHERE `object_type` = ? AND `object_id` = ?";
     $db_results = Dba::read($sql, array($object_type, $object_id));
     $results = array();
     while ($row = Dba::fetch_assoc($db_results)) {
         $results[] = $row['id'];
     }
     return $results;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:10,代码来源:share.class.php

示例14: resort_objects

 /**
  * resort_objects
  * This takes the existing objects, looks at the current
  * sort method and then re-sorts them This is internally
  * called by the set_sort() function
  */
 private function resort_objects()
 {
     // There are two ways to do this.. the easy way...
     // and the vollmer way, hopefully we don't have to
     // do it the vollmer way
     if ($this->is_simple()) {
         $sql = $this->get_sql(true);
     } else {
         // FIXME: this is fragile for large browses
         // First pull the objects
         $objects = $this->get_saved();
         // If there's nothing there don't do anything
         if (!count($objects) or !is_array($objects)) {
             return false;
         }
         $type = $this->get_type();
         $where_sql = "WHERE `{$type}`.`id` IN (";
         foreach ($objects as $object_id) {
             $object_id = Dba::escape($object_id);
             $where_sql .= "'{$object_id}',";
         }
         $where_sql = rtrim($where_sql, ',');
         $where_sql .= ")";
         $sql = $this->get_base_sql();
         $order_sql = " ORDER BY ";
         foreach ($this->_state['sort'] as $key => $value) {
             $order_sql .= $this->sql_sort($key, $value);
         }
         // Clean her up
         $order_sql = rtrim($order_sql, "ORDER BY ");
         $order_sql = rtrim($order_sql, ",");
         $sql = $sql . $this->get_join_sql() . $where_sql . $order_sql;
     }
     // if not simple
     $db_results = Dba::read($sql);
     $results = array();
     while ($row = Dba::fetch_assoc($db_results)) {
         $results[] = $row['id'];
     }
     $this->save_objects($results);
     return true;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:48,代码来源:query.class.php

示例15: get_access_lists

 /**
  * get_access_lists
  * returns a full listing of all access rules on this server
  */
 public static function get_access_lists()
 {
     $sql = 'SELECT `id` FROM `access_list`';
     $db_results = Dba::read($sql);
     $results = array();
     while ($row = Dba::fetch_assoc($db_results)) {
         $results[] = $row['id'];
     }
     return $results;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:14,代码来源:access.class.php


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