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


PHP Dba::write方法代码示例

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


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

示例1: insert

 /**
  * insert
  * This inserts a new record for the specified object
  * with the specified information, amazing!
  */
 public static function insert($type, $oid, $user, $agent = '')
 {
     $type = self::validate_type($type);
     $sql = "INSERT INTO `object_count` (`object_type`,`object_id`,`date`,`user`,`agent`) " . " VALUES (?, ?, ?, ?, ?)";
     $db_results = Dba::write($sql, array($type, $oid, time(), $user, $agent));
     if (!$db_results) {
         debug_event('statistics', 'Unabled to insert statistics:' . $sql, '3');
     }
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:14,代码来源:stats.class.php

示例2: insert

 /**
  * insert
  * This inserts a new record for the specified object
  * with the specified information, amazing!
  */
 public static function insert($type, $oid, $user, $agent = '', $location, $count_type = 'stream')
 {
     if (!self::is_already_inserted($type, $oid, $user)) {
         $type = self::validate_type($type);
         $latitude = null;
         $longitude = null;
         $geoname = null;
         if (isset($location['latitude'])) {
             $latitude = $location['latitude'];
         }
         if (isset($location['longitude'])) {
             $longitude = $location['longitude'];
         }
         if (isset($location['name'])) {
             $geoname = $location['name'];
         }
         $sql = "INSERT INTO `object_count` (`object_type`,`object_id`,`count_type`,`date`,`user`,`agent`, `geo_latitude`, `geo_longitude`, `geo_name`) " . " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
         $db_results = Dba::write($sql, array($type, $oid, $count_type, time(), $user, $agent, $latitude, $longitude, $geoname));
         if (Core::is_media($type)) {
             Useractivity::post_activity($user, 'play', $type, $oid);
         }
         if (!$db_results) {
             debug_event('statistics', 'Unabled to insert statistics:' . $sql, '3');
         }
     } else {
         debug_event('statistics', 'Statistics insertion ignored due to graceful delay.', '3');
     }
 }
开发者ID:cheese1,项目名称:ampache,代码行数:33,代码来源:stats.class.php

示例3: update

 /**
  * update
  *
  * This function updates the saved version with the current settings.
  */
 public function update(array $data = null)
 {
     if ($data && is_array($data)) {
         $this->name = $data['name'];
         $this->type = $data['pl_type'];
         $this->random = $data['random'];
         $this->limit = $data['limit'];
     }
     if (!$this->id) {
         return false;
     }
     $sql = "UPDATE `search` SET `name` = ?, `type` = ?, `rules` = ?, `logic_operator` = ?, `random` = ?, `limit` = ? WHERE `id` = ?";
     Dba::write($sql, array($this->name, $this->type, serialize($this->rules), $this->logic_operator, $this->random, $this->limit, $this->id));
     return $this->id;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:20,代码来源:search.class.php

示例4: update_380005

 /**
  * update_380005
  *
  * Add manual update flag on artist
  */
 public static function update_380005()
 {
     $retval = true;
     $sql = "ALTER TABLE `artist` ADD COLUMN `manual_update` SMALLINT( 1 ) DEFAULT '0'";
     $retval &= Dba::write($sql);
     return $retval;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:12,代码来源:update.class.php

示例5: remove_from_disk

 /**
  * Remove the video from disk.
  */
 public function remove_from_disk()
 {
     $deleted = parent::remove_from_disk();
     if ($deleted) {
         $sql = "DELETE FROM `tvshow_episode` WHERE `id` = ?";
         $deleted = Dba::write($sql, array($this->id));
     }
     return $deleted;
 }
开发者ID:nioc,项目名称:ampache,代码行数:12,代码来源:tvshow_episode.class.php

示例6: remove_from_disk

 public function remove_from_disk()
 {
     $deleted = true;
     $season_ids = $this->get_seasons();
     foreach ($season_ids as $id) {
         $season = new TVShow_Season($id);
         $deleted = $season->remove_from_disk();
         if (!$deleted) {
             debug_event('tvshow', 'Error when deleting the season `' . $id . '`.', 1);
             break;
         }
     }
     if ($deleted) {
         $sql = "DELETE FROM `tvshow` WHERE `id` = ?";
         $deleted = Dba::write($sql, array($this->id));
         if ($deleted) {
             Art::gc('tvshow', $this->id);
             Userflag::gc('tvshow', $this->id);
             Rating::gc('tvshow', $this->id);
             Shoutbox::gc('tvshow', $this->id);
             Useractivity::gc('tvshow', $this->id);
         }
     }
     return $deleted;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:25,代码来源:tvshow.class.php

示例7: set_rating

 /**
  * set_rating
  * This function sets the rating for the current object.
  * If no userid is passed in, we use the currently logged in user.
  */
 public function set_rating($rating, $user_id = null)
 {
     if (is_null($user_id)) {
         $user_id = $GLOBALS['user']->id;
     }
     $user_id = intval($user_id);
     debug_event('Rating', "Setting rating for {$this->type} {$this->id} to {$rating}", 5);
     // If score is -1, then remove rating
     if ($rating == '-1') {
         $sql = "DELETE FROM `rating` WHERE " . "`object_id` = ? AND " . "`object_type` = ? AND " . "`user` = ?";
         $params = array($this->id, $this->type, $user_id);
     } else {
         $sql = "REPLACE INTO `rating` " . "(`object_id`, `object_type`, `rating`, `user`) " . "VALUES (?, ?, ?, ?)";
         $params = array($this->id, $this->type, $rating, $user_id);
     }
     Dba::write($sql, $params);
     parent::add_to_cache('rating_' . $this->type . '_user' . $user_id, $this->id, $rating);
     foreach (Plugin::get_plugins('save_rating') as $plugin_name) {
         $plugin = new Plugin($plugin_name);
         if ($plugin->load($GLOBALS['user'])) {
             $plugin->_plugin->save_rating($this, $rating);
         }
     }
     return true;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:30,代码来源:rating.class.php

示例8: delete_track

 /**
  * delete_track
  * This deletes a track from the tmpplaylist
  */
 public function delete_track($id)
 {
     /* delete the track its self */
     $sql = "DELETE FROM `tmp_playlist_data` WHERE `id` = ?";
     Dba::write($sql, array($id));
     return true;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:11,代码来源:tmp_playlist.class.php

示例9: rebuild_all_preferences

 /**
  * rebuild_all_preferences
  * This rebuilds the user preferences for all installed users, called by the plugin functions
  */
 public static function rebuild_all_preferences()
 {
     // Clean out any preferences garbage left over
     $sql = "DELETE `user_preference`.* FROM `user_preference` " . "LEFT JOIN `user` ON `user_preference`.`user` = `user`.`id` " . "WHERE `user_preference`.`user` != -1 AND `user`.`id` IS NULL";
     Dba::write($sql);
     // Get only users who has less preferences than excepted
     // otherwise it would have significant performance issue with large user database
     $sql = "SELECT `user` FROM `user_preference` " . "GROUP BY `user` HAVING COUNT(*) < (" . "SELECT COUNT(`id`) FROM `preference` WHERE `catagory` != 'system')";
     $db_results = Dba::read($sql);
     while ($row = Dba::fetch_assoc($db_results)) {
         User::fix_preferences($row['user']);
     }
     return true;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:18,代码来源:user.class.php

示例10: add_wanted

 /**
  * Add a new wanted release.
  * @param string $mbid
  * @param int $artist
  * @param string $artist_mbid
  * @param string $name
  * @param int $year
  */
 public static function add_wanted($mbid, $artist, $artist_mbid, $name, $year)
 {
     $sql = "INSERT INTO `wanted` (`user`, `artist`, `artist_mbid`, `mbid`, `name`, `year`, `date`, `accepted`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
     $accept = $GLOBALS['user']->has_access('75') ? true : AmpConfig::get('wanted_auto_accept');
     $params = array($GLOBALS['user']->id, $artist, $artist_mbid, $mbid, $name, $year, time(), '0');
     Dba::write($sql, $params);
     if ($accept) {
         $wantedid = Dba::insert_id();
         $wanted = new Wanted($wantedid);
         $wanted->accept();
         database_object::remove_from_cache('wanted', $wantedid);
     }
 }
开发者ID:cheese1,项目名称:ampache,代码行数:21,代码来源:wanted.class.php

示例11: save_access

 public function save_access()
 {
     $sql = "UPDATE `share` SET `counter` = (`counter` + 1), lastvisit_date = ? WHERE `id` = ?";
     return Dba::write($sql, array(time(), $this->id));
 }
开发者ID:cheese1,项目名称:ampache,代码行数:5,代码来源:share.class.php

示例12: delete

 /**
  * delete
  * Deletes the catalog and everything associated with it
  * it takes the catalog id
  */
 public static function delete($catalog_id)
 {
     // Large catalog deletion can take time
     set_time_limit(0);
     // First remove the songs in this catalog
     $sql = "DELETE FROM `song` WHERE `catalog` = ?";
     $db_results = Dba::write($sql, array($catalog_id));
     // Only if the previous one works do we go on
     if (!$db_results) {
         return false;
     }
     $sql = "DELETE FROM `video` WHERE `catalog` = ?";
     $db_results = Dba::write($sql, array($catalog_id));
     if (!$db_results) {
         return false;
     }
     $catalog = self::create_from_id($catalog_id);
     $sql = 'DELETE FROM `catalog_' . $catalog->get_type() . '` WHERE catalog_id = ?';
     $db_results = Dba::write($sql, array($catalog_id));
     if (!$db_results) {
         return false;
     }
     // Next Remove the Catalog Entry it's self
     $sql = "DELETE FROM `catalog` WHERE `id` = ?";
     Dba::write($sql, array($catalog_id));
     // Run the cleaners...
     self::gc();
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:33,代码来源:catalog.class.php

示例13: create

 public static function create(array $data)
 {
     $subject = trim(strip_tags($data['subject']));
     $message = trim(strip_tags($data['message']));
     if (empty($subject)) {
         AmpError::add('subject', T_('Error: Subject Required'));
     }
     $to_user = User::get_from_username($data['to_user']);
     if (!$to_user->id) {
         AmpError::add('to_user', T_('Error: Unknown user'));
     }
     if (!AmpError::occurred()) {
         $from_user = $data['from_user'] ?: $GLOBALS['user']->id;
         $creation_date = $data['creation_date'] ?: time();
         $is_read = $data['is_read'] ?: 0;
         $sql = "INSERT INTO `user_pvmsg` (`subject`, `message`, `from_user`, `to_user`, `creation_date`, `is_read`) " . "VALUES (?, ?, ?, ?, ?, ?)";
         if (Dba::write($sql, array($subject, $message, $from_user, $to_user->id, $creation_date, $is_read))) {
             $insert_id = Dba::insert_id();
             // Never send email in case of user impersonation
             if (!isset($data['from_user']) && $insert_id) {
                 if (Preference::get_by_user($to_user->id, 'notify_email')) {
                     if (!empty($to_user->email)) {
                         $mailer = new Mailer();
                         $mailer->set_default_sender();
                         $mailer->recipient = $to_user->email;
                         $mailer->recipient_name = $to_user->fullname;
                         $mailer->subject = "[" . T_('Private Message') . "] " . $subject;
                         $mailer->message = sprintf(T_("You just received a new private message from %s.\n\n\n        ----------------------\n        %s\n        ----------------------\n\n        %s\n        "), $GLOBALS['user']->fullname, $message, AmpConfig::get('web_path') . "/pvmsg.php?action=show&pvmsg_id=" . $insert_id);
                         $mailer->send();
                     }
                 }
             }
             return $insert_id;
         }
     }
     return false;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:37,代码来源:privatemsg.class.php

示例14: gc

 /**
  * gc
  * This cleans up art that no longer has a corresponding object
  */
 public static function gc()
 {
     // iterate over our types and delete the images
     foreach (array('album', 'artist') as $type) {
         $sql = "DELETE FROM `image` USING `image` LEFT JOIN `" . $type . "` ON `" . $type . "`.`id`=" . "`image`.`object_id` WHERE `object_type`='" . $type . "' AND `" . $type . "`.`id` IS NULL";
         Dba::write($sql);
     }
     // foreach
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:13,代码来源:art.class.php

示例15: delete

 /**
  * delete
  * this function deletes a specific shoutbox entry
  */
 public function delete($shout_id)
 {
     // Delete the shoutbox post
     $shout_id = Dba::escape($shout_id);
     $sql = "DELETE FROM `user_shout` WHERE `id`='{$shout_id}'";
     Dba::write($sql);
 }
开发者ID:nioc,项目名称:ampache,代码行数:11,代码来源:shoutbox.class.php


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