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


PHP Dba::insert_id方法代码示例

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


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

示例1: __construct

 /**
  * constructor
  * This should be called
  */
 public function __construct($id = null, $cached = true)
 {
     $sid = session_id();
     if (is_null($id)) {
         $this->reset();
         if ($cached) {
             $data = serialize($this->_state);
             $sql = 'INSERT INTO `tmp_browse` (`sid`, `data`) ' . 'VALUES(?, ?)';
             Dba::write($sql, array($sid, $data));
             $this->id = Dba::insert_id();
         } else {
             $this->id = 'nocache';
         }
         return true;
     }
     $this->id = $id;
     $sql = 'SELECT `data` FROM `tmp_browse` ' . 'WHERE `id` = ? AND `sid` = ?';
     $db_results = Dba::read($sql, array($id, $sid));
     if ($results = Dba::fetch_assoc($db_results)) {
         $this->_state = unserialize($results['data']);
         return true;
     }
     Error::add('browse', T_('Browse not found or expired, try reloading the page'));
     return false;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:29,代码来源:query.class.php

示例2: create

 /**
  * create
  * This takes a key'd array of data as input and inserts a new license entry, it returns the auto_inc id
  * @param array $data
  * @return int
  */
 public static function create(array $data)
 {
     $sql = "INSERT INTO `license` (`name`,`description`,`external_link`) " . "VALUES (? , ?, ?)";
     Dba::write($sql, array($data['name'], $data['description'], $data['external_link']));
     $insert_id = Dba::insert_id();
     return $insert_id;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:13,代码来源:license.class.php

示例3: create

 public static function create($name, $description = '')
 {
     if (!empty($name)) {
         $sql = "INSERT INTO `broadcast` (`user`, `name`, `description`, `is_private`) VALUES (?, ?, ?, '1')";
         $params = array($GLOBALS['user']->id, $name, $description);
         Dba::write($sql, $params);
         return Dba::insert_id();
     }
     return 0;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:10,代码来源:broadcast.class.php

示例4: login

 /**
  * login
  */
 public static function login($input)
 {
     self::check_auth('dmap.loginresponse');
     // Create a new daap session
     $sql = "INSERT INTO `daap_session` (`creationdate`) VALUES (?)";
     Dba::write($sql, array(time()));
     $sid = Dba::insert_id();
     $o = self::tlv('dmap.status', 200);
     $o .= self::tlv('dmap.sessionid', $sid);
     $o = self::tlv('dmap.loginresponse', $o);
     self::apiOutput($o);
 }
开发者ID:cheese1,项目名称:ampache,代码行数:15,代码来源:daap_api.class.php

示例5: save

 /**
  * save
  *
  * Save this search to the database for use as a smart playlist
  */
 public function save()
 {
     // Make sure we have a unique name
     if (!$this->name) {
         $this->name = $GLOBALS['user']->username . ' - ' . date('Y-m-d H:i:s', time());
     }
     $sql = "SELECT `id` FROM `search` WHERE `name` = ?";
     $db_results = Dba::read($sql, array($this->name));
     if (Dba::num_rows($db_results)) {
         $this->name .= uniqid('', true);
     }
     $sql = "INSERT INTO `search` (`name`, `type`, `user`, `rules`, `logic_operator`, `random`, `limit`) VALUES (?, ?, ?, ?, ?, ?, ?)";
     Dba::write($sql, array($this->name, $this->type, $GLOBALS['user']->id, serialize($this->rules), $this->logic_operator, $this->random, $this->limit));
     $insert_id = Dba::insert_id();
     $this->id = $insert_id;
     return $insert_id;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:22,代码来源:search.class.php

示例6: check

 /**
  * check
  *
  * Checks for an existing tv show; if none exists, insert one.
  */
 public static function check($name, $year, $tvshow_summary, $readonly = false)
 {
     // null because we don't have any unique id like mbid for now
     if (isset(self::$_mapcache[$name]['null'])) {
         return self::$_mapcache[$name]['null'];
     }
     $id = 0;
     $exists = false;
     $trimmed = Catalog::trim_prefix(trim($name));
     $name = $trimmed['string'];
     $prefix = $trimmed['prefix'];
     if (!$exists) {
         $sql = 'SELECT `id` FROM `tvshow` WHERE `name` LIKE ? AND `year` = ?';
         $db_results = Dba::read($sql, array($name, $year));
         $id_array = array();
         while ($row = Dba::fetch_assoc($db_results)) {
             $key = 'null';
             $id_array[$key] = $row['id'];
         }
         if (count($id_array)) {
             $id = array_shift($id_array);
             $exists = true;
         }
     }
     if ($exists) {
         self::$_mapcache[$name]['null'] = $id;
         return $id;
     }
     if ($readonly) {
         return null;
     }
     $sql = 'INSERT INTO `tvshow` (`name`, `prefix`, `year`, `summary`) VALUES(?, ?, ?, ?)';
     $db_results = Dba::write($sql, array($name, $prefix, $year, $tvshow_summary));
     if (!$db_results) {
         return null;
     }
     $id = Dba::insert_id();
     self::$_mapcache[$name]['null'] = $id;
     return $id;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:45,代码来源:tvshow.class.php

示例7: insertRecord

 protected function insertRecord($properties)
 {
     $sql = 'INSERT INTO ' . $this->getTableName() . ' (' . implode(',', array_keys($properties)) . ')' . ' VALUES(' . implode(',', array_fill(0, count($properties), '?')) . ')';
     //print_r($properties);
     \Dba::write($sql, array_values($this->resolveObjects($properties)));
     return \Dba::insert_id();
 }
开发者ID:cheese1,项目名称:ampache,代码行数:7,代码来源:Repository.php

示例8: insert

 /**
  * insert
  *
  * This inserts the song preview described by the passed array
  */
 public static function insert($results)
 {
     $sql = 'INSERT INTO `song_preview` (`file`, `album_mbid`, `artist`, `artist_mbid`, `title`, `disk`, `track`, `mbid`, `session`) ' . ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)';
     $db_results = Dba::write($sql, array($results['file'], $results['album_mbid'], $results['artist'], $results['artist_mbid'], $results['title'], $results['disk'], $results['track'], $results['mbid'], $results['session']));
     if (!$db_results) {
         debug_event('song_preview', 'Unable to insert ' . $results[''], 2);
         return false;
     }
     return Dba::insert_id();
 }
开发者ID:cheese1,项目名称:ampache,代码行数:15,代码来源:song_preview.class.php

示例9: create_share

 public static function create_share($object_type, $object_id, $allow_stream = true, $allow_download = true, $expire = 0, $secret = '', $max_counter = 0, $description = '')
 {
     $object_type = self::format_type($object_type);
     if (empty($object_type)) {
         return '';
     }
     if (!$allow_stream && !$allow_download) {
         return '';
     }
     $sql = "INSERT INTO `share` (`user`, `object_type`, `object_id`, `creation_date`, `allow_stream`, `allow_download`, `expire_days`, `secret`, `counter`, `max_counter`, `description`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
     $params = array($GLOBALS['user']->id, $object_type, $object_id, time(), $allow_stream ?: 0, $allow_download ?: 0, $expire, $secret, 0, $max_counter, $description);
     Dba::write($sql, $params);
     $id = Dba::insert_id();
     $url = self::get_url($id, $secret);
     // Get a shortener url if any available
     foreach (Plugin::get_plugins('shortener') as $plugin_name) {
         try {
             $plugin = new Plugin($plugin_name);
             if ($plugin->load($GLOBALS['user'])) {
                 $short_url = $plugin->_plugin->shortener($url);
                 if (!empty($short_url)) {
                     $url = $short_url;
                     break;
                 }
             }
         } catch (Exception $e) {
             debug_event('share', 'Share plugin error: ' . $e->getMessage(), '1');
         }
     }
     $sql = "UPDATE `share` SET `public_url` = ? WHERE `id` = ?";
     Dba::write($sql, array($url, $id));
     return $id;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:33,代码来源:share.class.php

示例10: insert

 /**
  * insert
  * This inserts a new preference into the preference table
  * it does NOT sync up the users, that should be done independently
  */
 public static function insert($name, $description, $default, $level, $type, $catagory)
 {
     $sql = "INSERT INTO `preference` (`name`,`description`,`value`,`level`,`type`,`catagory`) " . "VALUES (?, ?, ?, ?, ?, ?)";
     $db_results = Dba::write($sql, array($name, $description, $default, intval($level), $type, $catagory));
     if (!$db_results) {
         return false;
     }
     $id = Dba::insert_id();
     $params = array($id, $default);
     $sql = "INSERT INTO `user_preference` VALUES (-1,?,?)";
     $db_results = Dba::write($sql, $params);
     if (!$db_results) {
         return false;
     }
     if ($catagory !== "system") {
         $sql = "INSERT INTO `user_preference` SELECT `user`.`id`, ?, ? FROM `user`";
         $db_results = Dba::write($sql, $params);
         if (!$db_results) {
             return false;
         }
     }
     return true;
 }
开发者ID:nioc,项目名称:ampache,代码行数:28,代码来源:preference.class.php

示例11: create

 /**
  * create
  * This function creates an empty playlist, gives it a name and type
  * Assumes $GLOBALS['user']->id as the user
  */
 public static function create($name, $type)
 {
     $sql = "INSERT INTO `playlist` (`name`,`user`,`type`,`date`) VALUES (?, ?, ?, ?)";
     Dba::write($sql, array($name, $GLOBALS['user']->id, $type, time()));
     $insert_id = Dba::insert_id();
     return $insert_id;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:12,代码来源:playlist.class.php

示例12: check

 /**
  * check
  *
  * Checks for an existing artist; if none exists, insert one.
  */
 public static function check($name, $mbid = null, $readonly = false)
 {
     $trimmed = Catalog::trim_prefix(trim($name));
     $name = $trimmed['string'];
     $prefix = $trimmed['prefix'];
     if ($mbid == '') {
         $mbid = null;
     }
     if (!$name) {
         $name = T_('Unknown (Orphaned)');
         $prefix = null;
     }
     if (isset(self::$_mapcache[$name][$mbid])) {
         return self::$_mapcache[$name][$mbid];
     }
     $id = 0;
     $exists = false;
     if ($mbid) {
         $sql = 'SELECT `id` FROM `artist` WHERE `mbid` = ?';
         $db_results = Dba::read($sql, array($mbid));
         if ($row = Dba::fetch_assoc($db_results)) {
             $id = $row['id'];
             $exists = true;
         }
     }
     if (!$exists) {
         $sql = 'SELECT `id`, `mbid` FROM `artist` WHERE `name` LIKE ?';
         $db_results = Dba::read($sql, array($name));
         $id_array = array();
         while ($row = Dba::fetch_assoc($db_results)) {
             $key = $row['mbid'] ?: 'null';
             $id_array[$key] = $row['id'];
         }
         if (count($id_array)) {
             if ($mbid) {
                 if (isset($id_array['null']) && !$readonly) {
                     $sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?';
                     Dba::write($sql, array($mbid, $id_array['null']));
                 }
                 if (isset($id_array['null'])) {
                     $id = $id_array['null'];
                     $exists = true;
                 }
             } else {
                 // Pick one at random
                 $id = array_shift($id_array);
                 $exists = true;
             }
         }
     }
     if ($exists) {
         self::$_mapcache[$name][$mbid] = $id;
         return $id;
     }
     if ($readonly) {
         return null;
     }
     $sql = 'INSERT INTO `artist` (`name`, `prefix`, `mbid`) ' . 'VALUES(?, ?, ?)';
     $db_results = Dba::write($sql, array($name, $prefix, $mbid));
     if (!$db_results) {
         return null;
     }
     $id = Dba::insert_id();
     self::$_mapcache[$name][$mbid] = $id;
     return $id;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:71,代码来源:artist.class.php

示例13: check

 /**
  * check
  *
  * Searches for an album; if none is found, insert a new one.
  */
 public static function check($name, $year = 0, $disk = 0, $mbid = null, $readonly = false)
 {
     if ($mbid == '') {
         $mbid = null;
     }
     $trimmed = Catalog::trim_prefix(trim($name));
     $name = $trimmed['string'];
     $prefix = $trimmed['prefix'];
     // Not even sure if these can be negative, but better safe than llama.
     $year = abs(intval($year));
     $disk = abs(intval($disk));
     if (!$name) {
         $name = T_('Unknown (Orphaned)');
         $year = 0;
         $disk = 0;
     }
     if (isset(self::$_mapcache[$name][$year][$disk][$mbid])) {
         return self::$_mapcache[$name][$year][$disk][$mbid];
     }
     $sql = 'SELECT `id` FROM `album` WHERE `name` = ? AND `disk` = ? AND `year` = ? AND `mbid` ';
     $params = array($name, $disk, $year);
     if ($mbid) {
         $sql .= '= ? ';
         $params[] = $mbid;
     } else {
         $sql .= 'IS NULL ';
     }
     $sql .= 'AND `prefix` ';
     if ($prefix) {
         $sql .= '= ?';
         $params[] = $prefix;
     } else {
         $sql .= 'IS NULL';
     }
     $db_results = Dba::read($sql, $params);
     if ($row = Dba::fetch_assoc($db_results)) {
         $id = $row['id'];
         self::$_mapcache[$name][$year][$disk][$mbid] = $id;
         return $id;
     }
     if ($readonly) {
         return null;
     }
     $sql = 'INSERT INTO `album` (`name`, `prefix`, `year`, `disk`, `mbid`) VALUES (?, ?, ?, ?, ?)';
     $db_results = Dba::write($sql, array($name, $prefix, $year, $disk, $mbid));
     if (!$db_results) {
         return null;
     }
     $id = Dba::insert_id();
     // Remove from wanted album list if any request on it
     if (!empty($mbid) && AmpConfig::get('wanted')) {
         try {
             Wanted::delete_wanted_release($mbid);
         } catch (Exception $e) {
             debug_event('wanted', 'Cannot process wanted releases auto-removal check: ' . $e->getMessage(), '1');
         }
     }
     self::$_mapcache[$name][$year][$disk][$mbid] = $id;
     return $id;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:65,代码来源:album.class.php

示例14: create

 public static function create(array $data)
 {
     $feed = $data['feed'];
     // Feed must be http/https
     if (strpos($feed, "http://") !== 0 && strpos($feed, "https://") !== 0) {
         AmpError::add('feed', T_('Wrong feed url'));
     }
     $catalog_id = intval($data['catalog']);
     if ($catalog_id <= 0) {
         AmpError::add('catalog', T_('Target catalog required'));
     } else {
         $catalog = Catalog::create_from_id($catalog_id);
         if ($catalog->gather_types !== "podcast") {
             AmpError::add('catalog', T_('Wrong target catalog type'));
         }
     }
     if (AmpError::occurred()) {
         return false;
     }
     $title = T_('Unknown');
     $website = null;
     $description = null;
     $language = null;
     $copyright = null;
     $generator = null;
     $lastbuilddate = 0;
     $episodes = array();
     $arturl = '';
     $xmlstr = file_get_contents($feed);
     if ($xmlstr === false) {
         AmpError::add('feed', T_('Cannot access the feed.'));
     } else {
         $xml = simplexml_load_string($xmlstr);
         if ($xml === false) {
             AmpError::add('feed', T_('Cannot read the feed.'));
         } else {
             $title = html_entity_decode($xml->channel->title);
             $website = $xml->channel->link;
             $description = html_entity_decode($xml->channel->description);
             $language = $xml->channel->language;
             $copyright = html_entity_decode($xml->channel->copyright);
             $generator = html_entity_decode($xml->channel->generator);
             $lastbuilddatestr = $xml->channel->lastBuildDate;
             if ($lastbuilddatestr) {
                 $lastbuilddate = strtotime($lastbuilddatestr);
             }
             if ($xml->channel->image) {
                 $arturl = $xml->channel->image->url;
             }
             $episodes = $xml->channel->item;
         }
     }
     if (AmpError::occurred()) {
         return false;
     }
     $sql = "INSERT INTO `podcast` (`feed`, `catalog`, `title`, `website`, `description`, `language`, `copyright`, `generator`, `lastbuilddate`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
     $db_results = Dba::write($sql, array($feed, $catalog_id, $title, $website, $description, $language, $copyright, $generator, $lastbuilddate));
     if ($db_results) {
         $id = Dba::insert_id();
         $podcast = new Podcast($id);
         $dirpath = $podcast->get_root_path();
         if (!is_dir($dirpath)) {
             if (mkdir($dirpath) === false) {
                 debug_event('podcast', 'Cannot create directory ' . $dirpath, 1);
             }
         }
         if (!empty($arturl)) {
             $art = new Art($id, 'podcast');
             $art->insert_url($arturl);
         }
         if (count($episodes) > 0) {
             $podcast->add_episodes($episodes);
         }
     }
     return $db_results;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:76,代码来源:podcast.class.php

示例15: update_recommendation_cache

 protected static function update_recommendation_cache($type, $id, $recommendations)
 {
     self::delete_recommendation_cache($type, $id);
     $sql = "INSERT INTO `recommendation` (`object_type`, `object_id`, `last_update`) VALUES (?, ?, ?)";
     Dba::write($sql, array($type, $id, time()));
     $insertid = Dba::insert_id();
     foreach ($recommendations as $recommendation) {
         $sql = "INSERT INTO `recommendation_item` (`recommendation`, `recommendation_id`, `name`, `rel`, `mbid`) VALUES (?, ?, ?, ?, ?)";
         Dba::write($sql, array($insertid, $recommendation['id'], $recommendation['name'], $recommendation['rel'], $recommendation['mbid']));
     }
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:11,代码来源:recommendation.class.php


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