• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Kofradia\DB类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add_emails

 /**
  * Legg til e-post i køen
  * @param object email $email
  * @param array receivers
  * @param string subject
  * @param bool sende e-posten med en gang
  */
 public static function add_emails(email $email, $receivers, $subject, $send_now = false)
 {
     global $_base;
     if (!is_array($receivers)) {
         $receivers = array($receivers);
     }
     if (!isset($email->data) || !$email->data) {
         throw new HSException("Email must be formatted before input.");
     }
     // sett opp tag
     $id = uniqid("", true);
     $add = array();
     foreach ($receivers as $item) {
         $more = $send_now ? ", " . (time() + self::$timeout) . ", " . \Kofradia\DB::quote($id) : "";
         $add[] = "(" . \Kofradia\DB::quote($item) . "," . \Kofradia\DB::quote($subject) . "," . \Kofradia\DB::quote($email->data[0]) . "," . \Kofradia\DB::quote($email->data[1]) . "," . \Kofradia\DB::quote($email->params) . "{$more})";
     }
     // noen vi skal legge til?
     if (count($add) > 0) {
         $more = $send_now ? ", m_active_end, m_active_id" : "";
         \Kofradia\DB::get()->exec("INSERT INTO mailer (m_receiver, m_subject, m_headers, m_body, m_params{$more}) VALUES " . implode(", ", $add));
     }
     // skal e-postene sendes med en gang?
     if ($send_now) {
         return array($add, self::send_tag($id));
     }
     return count($add);
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:34,代码来源:class.mailer.php


示例2: getBestRankers

 /**
  * Hent beste ranker siste 24 timer
  */
 public static function getBestRankers($limit = null)
 {
     $limit = (int) ($limit ?: 1);
     // tidsperiode
     $d = \ess::$b->date->get();
     $a = $d->format("H") < 21 ? 2 : 1;
     $d->modify("-{$a} day");
     $d->setTime(21, 0, 0);
     $date_from = $d->format("U");
     $d->modify("+1 day");
     $date_to = $d->format("U");
     // hent spiller
     $result = \Kofradia\DB::get()->query("\n\t\t\tSELECT up_id, up_name, up_access_level, sum_uhi_points, up_points, up_last_online, up_profile_image_url, upr_rank_pos\n\t\t\tFROM\n\t\t\t\t(\n\t\t\t\t\tSELECT uhi_up_id, SUM(uhi_points) sum_uhi_points\n\t\t\t\t\tFROM users_hits\n\t\t\t\t\tWHERE uhi_secs_hour >= {$date_from} AND uhi_secs_hour < {$date_to}\n\t\t\t\t\tGROUP BY uhi_up_id\n\t\t\t\t\tHAVING sum_uhi_points > 0\n\t\t\t\t\tORDER BY sum_uhi_points DESC\n\t\t\t\t\tLIMIT {$limit}\n\t\t\t\t) ref,\n\t\t\t\tusers_players\n\t\t\t\tLEFT JOIN users_players_rank ON upr_up_id = up_id\n\t\t\tWHERE uhi_up_id = up_id");
     if ($result->rowCount() == 0) {
         return array();
     }
     $players = array();
     $up_id = array();
     while ($row = $result->fetch()) {
         $row['ff_links'] = array();
         $players[$row['up_id']] = $row;
         $up_id[] = $row['up_id'];
     }
     // hent familier hvor spilleren er medlem
     $ff = \ff::get_ff_list($up_id, \ff::TYPE_FAMILIE);
     foreach ($ff as $row) {
         $players[$row['ffm_up_id']]['ff'][] = $row;
         $players[$row['ffm_up_id']]['ff_links'][] = $row['link'];
     }
     return $players;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:34,代码来源:Stats.php


示例3: get

 /**
  * Get specific donation
  *
  * @param int Donation ID
  * @return \Kofradia\Donation
  */
 public static function get($d_id)
 {
     $d_id = (int) $d_id;
     $result = DB::get()->query("\n\t\t\tSELECT d_id, d_up_id, d_time, d_amount\n\t\t\tFROM donations\n\t\t\tWHERE d_id = {$d_id}");
     if ($row = $result->fetch()) {
         return static::load($row);
     }
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:14,代码来源:Donation.php


示例4: reload

 /**
  * Load settings and save to cache
  */
 public static function reload()
 {
     $result = \Kofradia\DB::get()->query("SELECT id, name, value FROM settings");
     \game::$settings = array();
     while ($row = $result->fetch()) {
         \game::$settings[$row['name']] = array("id" => $row['id'], "value" => $row['value']);
     }
     // keep for 1 hour
     \cache::store("settings", \game::$settings, 3600);
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:13,代码来源:Settings.php


示例5: set

 /**
  * Sett telleren til bestemt verdi
  * @param string $name
  * @param integer $count
  */
 public static function set($name, $value)
 {
     global $_base;
     $value = (int) $value;
     // forsøk å sett telleren til bestemt verdi
     $affected = \Kofradia\DB::get()->exec("UPDATE tasks SET t_ant = {$value} WHERE t_name = " . \Kofradia\DB::quote($name));
     // oppdater cache
     self::load(true);
     return $affected;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:15,代码来源:class.tasks.php


示例6: vote

 /**
  * Vote on this
  *
  * @param \user User voting
  * @return bool
  */
 public function vote(\user $user)
 {
     $a = \Kofradia\DB::get()->exec("\n\t\t\tINSERT IGNORE INTO polls_votes\n\t\t\tSET pv_p_id = {$this->poll->id}, pv_po_id = {$this->id}, pv_up_id = {$user->player->id}, pv_time = " . time());
     if ($a > 0) {
         \Kofradia\DB::get()->exec("UPDATE polls_options SET po_votes = po_votes + 1 WHERE po_id = {$this->id}");
         \Kofradia\DB::get()->exec("UPDATE polls SET p_votes = p_votes + 1 WHERE p_id = {$this->poll->id}");
         // delete vote cache
         \cache::delete("polls_options_list");
     }
     return $ok;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:17,代码来源:PollOption.php


示例7: get_latest

 /**
  * Hent siste oppføringene
  */
 public static function get_latest($limit = 20)
 {
     $limit = (int) $limit;
     if ($limit <= 0) {
         $limit = 1;
     }
     $result = \Kofradia\DB::get()->query("SELECT lf_time, lf_html FROM livefeed ORDER BY lf_time DESC, lf_id DESC LIMIT {$limit}");
     $data = array();
     while ($row = $result->fetch()) {
         $data[] = $row;
     }
     return $data;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:16,代码来源:class.livefeed.php


示例8: action_betingelser

 /**
  * Show betingelser
  */
 public function action_betingelser()
 {
     \ess::$b->page->add_title("Betingelser");
     $user = \login::$logged_in ? \login::$user : null;
     // markere betingelsene som sett?
     $updated = false;
     if ($user && ($user->data['u_tos_version'] != intval(Settings::get('tos_version')) || empty($user->data['u_tos_accepted_time']))) {
         $updated = true;
         $user->data['u_tos_version'] = intval(Settings::get("tos_version"));
         $user->data['u_tos_accepted_time'] = time();
         \Kofradia\DB::get()->exec("\n\t\t\t\tUPDATE users\n\t\t\t\tSET u_tos_version = " . $user->data['u_tos_version'] . ",\n\t\t\t\t\tu_tos_accepted_time = " . time() . "\n\t\t\t\tWHERE u_id = " . $user->id);
     }
     return View::forge("misc/betingelser", array("tos_version" => Settings::get("tos_version"), "tos_update" => Settings::get("tos_update"), "tos" => Settings::get("tos"), "user" => $user, "updated" => $updated));
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:17,代码来源:Misc.php


示例9: addToDb

 /**
  * Add to database
  */
 public function addToDb()
 {
     // already in db?
     if ($this->id) {
         return;
     }
     Hendelser::incSetting("count_events");
     foreach ($this->getDescriptionHTML() as $text) {
         if ($this->event_name == "push") {
             Hendelser::incSetting("count_code", $this->getLogCount());
         } else {
             Hendelser::incSetting("count_other", $this->getLogCount());
         }
     }
     \Kofradia\DB::get()->exec("\n\t\t\tINSERT INTO github_log\n\t\t\tSET gl_time = " . $this->event_time->getTimestamp() . ", gl_event_type = " . \Kofradia\DB::quote($this->event_name) . ",\n\t\t\t    gl_contents = " . \Kofradia\DB::quote(serialize($this)) . ", gl_log_count = " . $this->getLogCount());
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:19,代码来源:Event.php


示例10: update_data

 /**
  * Oppdater data
  */
 public static function update_data()
 {
     global $_base;
     // hent data
     $data = self::get_changes();
     if (!$data) {
         return false;
     }
     // lagre ny data
     $data_sql = \Kofradia\DB::quote(serialize($data));
     \Kofradia\DB::get()->exec("INSERT INTO settings SET name = 'wordpress_data', value = {$data_sql} ON DUPLICATE KEY UPDATE value = {$data_sql}");
     // sjekk for ny data
     self::check_new($data);
     // last inn settings på nytt
     require PATH_APP . "/scripts/update_db_settings.php";
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:19,代码来源:class.wordpress_entries.php


示例11: set_headers

 /** Sett headers */
 public static function set_headers()
 {
     // kan ikke sende headers hvis headers allerede er sendt
     if (headers_sent()) {
         return;
     }
     // sett riktig retur
     self::type_header(self::$type);
     // sett script tid
     if (defined("SCRIPT_START")) {
         header("X-HSW-Time: " . round(microtime(true) - SCRIPT_START, 4));
     }
     // sett database info
     if ($profiler = \Kofradia\DB::getProfiler()) {
         header("X-HSW-Queries: " . $profiler->num);
         header("X-HSW-Queries-Time: " . round($profiler->time, 4));
     }
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:19,代码来源:ajax.php


示例12: __construct

 /** Kontroller alle artikler */
 public function __construct()
 {
     // hent alle artikkelene
     $result = \Kofradia\DB::get()->query("\n\t\t\tSELECT ffna_id, ffna_ffn_id, ffna_created_time, ffna_updated_time, ffna_title, ffna_text, ffna_published, ffna_published_time, ffna_price, ff_id, ff_name, up_name, u_email, up_access_level\n\t\t\tFROM ff_newspapers_articles\n\t\t\t\tLEFT JOIN ff_members ON ffm_ff_id = ffna_ff_id AND ffm_up_id = ffna_up_id AND ffm_status != 2, users, users_players, ff\n\t\t\tWHERE ffna_ffn_id = 0 AND ffm_up_id IS NULL AND ff_id = ffna_ff_id AND up_id = ffna_up_id AND u_id = up_u_id");
     // ingen artikler?
     if ($result->rowCount() == 0) {
         $this->deleted = 0;
         return;
     }
     $this->email = new email();
     $this->headers['Bcc'] = "[email protected]";
     // send hver artikkel på e-post og slett artikkelen
     while ($row = $result->fetch()) {
         // send e-post
         $this->send_email($row);
         // slett artikkelen
         \Kofradia\DB::get()->exec("DELETE FROM ff_newspapers_articles WHERE ffna_id = {$row['ffna_id']}");
     }
     $this->deleted = $result->rowCount();
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:21,代码来源:class.avis_slett_artikler.php


示例13: getForumNew

 /**
  * Hent nyeste tråder og svar i forumet
  */
 public static function getForumNew($limit = null)
 {
     $limit = (int) ($limit ?: 5);
     // hent forumdata
     $topics = \Kofradia\DB::get()->query("\n\t\t\tSELECT ft_id, ft_title, ft_time, ft_up_id, ft_fse_id, fse_name\n\t\t\tFROM forum_topics\n\t\t\t\tLEFT JOIN forum_sections ON ft_fse_id = fse_id\n\t\t\tWHERE fse_id IN (1,2,3) AND ft_deleted = 0\n\t\t\tORDER BY ft_time DESC\n\t\t\tLIMIT {$limit}");
     $replies = \Kofradia\DB::get()->query("\n\t\t\tSELECT fr_id, fr_ft_id, fr_time, fr_up_id, ft_title, fse_name\n\t\t\tFROM forum_replies\n\t\t\t\tLEFT JOIN forum_topics ON fr_ft_id = ft_id AND ft_deleted = 0\n\t\t\t\tLEFT JOIN forum_sections ON ft_fse_id = fse_id\n\t\t\tWHERE fse_id IN (1,2,3) AND fr_deleted = 0\n\t\t\tORDER BY fr_time DESC\n\t\t\tLIMIT {$limit}");
     $data = array();
     $times = array();
     while ($row = $topics->fetch()) {
         $data[] = array('topic_id' => $row['ft_id'], 'time' => $row['ft_time'], 'user' => $row['ft_up_id'], 'title' => $row['ft_title'], 'section' => $row['fse_name'], 'reply' => false);
         $times[] = $row['ft_time'];
     }
     while ($row = $replies->fetch()) {
         $data[] = array('topic_id' => $row['fr_ft_id'], 'reply_id' => $row['fr_id'], 'time' => $row['fr_time'], 'user' => $row['fr_up_id'], 'title' => $row['ft_title'], 'section' => $row['fse_name'], 'reply' => true);
         $times[] = $row['fr_time'];
     }
     // sorter data
     array_multisort($times, SORT_DESC, SORT_NUMERIC, $data);
     return array_slice($data, 0, $limit);
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:23,代码来源:Helpers.php


示例14: action_online_top

 /**
  * Shows a recordlist of online users within each hour
  */
 public function action_online_top()
 {
     \ess::$b->page->add_title("Antall pålogget rekorder");
     // hent stats
     $result = \Kofradia\DB::get()->query("SELECT name, extra, value, time FROM sitestats");
     $sitestats = array();
     $sitestats_max = array();
     while ($row = $result->fetch()) {
         $sitestats[$row['name']][$row['extra']] = $row;
         $sitestats[$row['name']][$row['extra']] = $row;
         if (!array_key_exists($row['name'], $sitestats_max)) {
             $sitestats_max[$row['name']] = $row;
         } else {
             if ($row['value'] > $sitestats_max[$row['name']]['value']) {
                 $sitestats_max[$row['name']] = $row;
             }
         }
     }
     return View::forge("stats/online_top", array("sitestats" => $sitestats, "sitestats_max" => $sitestats_max));
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:23,代码来源:Stats.php


示例15: visliste

function visliste($name, $where)
{
    global $_base;
    $result = \Kofradia\DB::get()->query("SELECT up_id, up_name, up_access_level, up_last_online FROM users_players WHERE {$where} ORDER BY up_name");
    // hopp over hvis det ikke finnes noen
    if ($result->rowCount() == 0) {
        return;
    }
    echo '
		<h2 class="bg1">' . $name . '<span class="left2"></span><span class="right2"></span></h2>
		<div class="bg1">
			<dl class="dd_right">';
    while ($row = $result->fetch()) {
        echo '
				<dt>' . game::profile_link($row['up_id'], $row['up_name'], $row['up_access_level']) . '</dt>
				<dd>' . game::timespan($row['up_last_online'], game::TIME_ABS | game::TIME_NOBOLD) . '</dd>';
    }
    echo '
			</dl>
		</div>';
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:21,代码来源:crewet.php


示例16: save_user_backup

function save_user_backup()
{
    global $_base;
    static $i = 0;
    $i++;
    $date = date("Ymd_His");
    $url = GAMELOG_DIR . "/info_db_" . $date . "_" . $i . ".txt";
    $result = \Kofradia\DB::get()->query("SELECT up_id, up_name, up_points, up_bank, up_cash, up_last_online, up_hits, up_interest_last FROM users_players");
    if ($fh = fopen($url, "w")) {
        $row = $result->fetch();
        $fields = array_keys($row);
        fwrite($fh, "column information:\n" . implode(",", $fields));
        do {
            fwrite($fh, "\n" . implode(",", $row));
        } while ($row = $result->fetch());
        fclose($fh);
    } else {
        echo "error writing to {$url}\r\n";
    }
    return $url;
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:21,代码来源:func.save_user_backup.php


示例17: action_notify

 /**
  * Handle notify URLs from PayPal
  */
 public function action_notify()
 {
     file_put_contents(PATH_ROOT . "/paypal.log", print_r($_POST, true), FILE_APPEND);
     // TODO: remove this when tested on production
     if (!isset($_POST['receiver_email']) || $_POST['receiver_email'] != '[email protected]') {
         die;
     }
     // should really check for duplicates, but we don't
     // but it must be "completed"
     if (!isset($_POST['payment_status']) || $_POST['payment_status'] != 'Completed') {
         die;
     }
     // verify it
     $verify = Donation::verifyPayPalData($_POST);
     if (!$verify) {
         die;
     }
     // check for user etc
     $custom = postval("custom");
     if (!preg_match('~^(.*):(.*);public=(0|1)$~', $custom, $matches)) {
         die;
     }
     trigger_error("should add");
     $player = null;
     if ($matches[1] != "gjest") {
         // find this player
         $result = DB::get()->query("\n\t\t\t\tSELECT up_id\n\t\t\t\tFROM users_players\n\t\t\t\t\tLEFT JOIN users ON up_u_id = u_id\n\t\t\t\t\tLEFT JOIN sessions ON u_id = ses_u_id\n\t\t\t\tWHERE ses_id = " . DB::quote($matches[1]) . " AND up_id = " . DB::quote($matches[2]) . " LIMIT 1");
         if ($up_id = $result->fetchColumn(0)) {
             $player = \player::get($up_id);
         }
     }
     $time = \ess::$b->date->parse(postval("payment_date"));
     // add it
     $d = Donation::create(postval("mc_gross"), $time, $matches[3] ? $player->id : null);
     putlog("CREWCHAN", sprintf("%%uDONASJON:%%u %s %s ble donert av %s", postval("mc_currency"), postval("mc_gross"), $player ? $player->data['up_name'] . ($matches[3] ? ' (synlig)' : ' (som anonym)') : 'anonym gjest'));
     // no output
     die;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:41,代码来源:Donations.php


示例18: set_time_limit

    // hindre scriptet i å kjøre to ganger
    if (defined("SCHEDULER")) {
        die;
    }
}
set_time_limit(0);
define("SCHEDULER", true);
define("SCHEDULER_REPEATING", true);
sess_start();
echo "Utfører rutine regelmessig.\n";
// kjør rutiner (autoload klassen)
ess::$b->scheduler = new scheduler();
// utfør rutiner regelmessig
while (true) {
    // finn ut når neste rutine skal utføres
    $result = \Kofradia\DB::get()->query("\n\t\tSELECT GREATEST(s_next, s_expire) next\n\t\tFROM scheduler\n\t\tWHERE s_active = 1\n\t\tORDER BY next\n\t\tLIMIT 1");
    $row = $result->fetch();
    $next = false;
    if ($row) {
        $next = $row['next'];
    }
    $t = time();
    $s = ess::$b->date->get($t)->format("s");
    $max = $t + 60 - $s;
    if (!$next || $next > $max) {
        $next = $max;
    }
    printf("Neste: %s\n", ess::$b->date->get($next)->format(date::FORMAT_SEC));
    // sov
    $sleep = max(0.1, $next - microtime(true));
    putlog("LOG", sprintf("Venter %.2f sekunder til neste.\n", $sleep));
开发者ID:Kuzat,项目名称:kofradia,代码行数:31,代码来源:scheduler_background.php


示例19: update

 /** Hent ut data for brukeren og sørg for at den er oppdatert */
 public function update($data = NULL, $force_update = NULL)
 {
     global $_base;
     // hente data lokalt?
     if ($data === NULL && $this->data) {
         $data = $this->data['sw_xml'];
     }
     // forsøk å lese data
     $xml = $this->read_xml($data);
     $update = $force_update !== false;
     // sjekk om data ikke skal oppdateres
     if ($xml && $force_update === NULL) {
         $last_real_update = $_base->date->parse($xml->GeneratedTime)->format("U");
         // gått mindre enn en time?
         if ($last_real_update > time() - 3600) {
             // ikke oppdater data
             $update = false;
         }
     }
     // oppdatere data?
     if ($update) {
         $data = $this->get_xml();
         $xml_update = $this->read_xml($data);
         // gyldig?
         if ($xml_update) {
             $xml = $xml_update;
             // lagre data
             \Kofradia\DB::get()->exec("UPDATE stats_whatpulse SET sw_time_update = " . time() . ", sw_xml = " . \Kofradia\DB::quote($data) . " WHERE sw_userid = {$this->user_id}");
         }
     }
     $this->xml = $xml;
     return (bool) $xml;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:34,代码来源:class.whatpulse.php


示例20: getFFPlayers

 /**
  * Get the players that are in a same FF as us
  *
  * We don't want to attack a allied
  *
  * TODO: Move this to player-class for reuse
  *
  * @return array(int up_id, ..)
  */
 protected function getFFPlayers()
 {
     $result = \Kofradia\DB::get()->prepare("\n\t\t\tSELECT DISTINCT f2.ffm_up_id\n\t\t\tFROM ff_members f1\n\t\t\t\tJOIN ff ON ff_id = f1.ffm_ff_id AND ff_is_crew = 0\n\t\t\t\tJOIN ff_members f2 ON f1.ffm_ff_id = f2.ffm_ff_id AND f2.ffm_status = 1 AND f2.ffm_up_id != f1.ffm_up_id\n\t\t\tWHERE f1.ffm_up_id = ? AND f1.ffm_status = 1");
     $result->execute(array($this->ut->up->id));
     $up_ids = array();
     while ($row = $result->fetch()) {
         $up_ids[] = $row['ffm_up_id'];
     }
     return $up_ids;
 }
开发者ID:Kuzat,项目名称:kofradia,代码行数:19,代码来源:Option.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP LaravelFormBuilder\FormBuilder类代码示例发布时间:2022-05-23
下一篇:
PHP Menu\ItemInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap