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


PHP DB::get方法代码示例

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


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

示例12: 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

示例13: __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'] = "henrist@henrist.net";
     // 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

示例14: 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

示例15: 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


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