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


PHP db_init函数代码示例

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


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

示例1: s2map

 function s2map($file)
 {
     global $config;
     $this->sql = db_init($config['sql']);
     $this->hash = md5_file($file);
     $this->file = $file;
 }
开发者ID:Return-To-The-Roots,项目名称:s2map-php,代码行数:7,代码来源:s2map.php

示例2: send_msg

function send_msg($sender, $message)
{
    if (!empty($sender) && !empty($message)) {
        $sender = mysql_real_escape_string($sender);
        $mesage = mysql_real_escape_string($message);
        $flag = 0;
        $db = db_init();
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        // setting error mode for pdo
        $query = $db->prepare("INSERT INTO `chat2`.`chat` VALUES (null, :sender, :message )");
        $query->bindValue(':sender', $sender, PDO::PARAM_STR);
        $query->bindValue(':message', $message, PDO::PARAM_STR);
        try {
            // implementing try catch and handling exception
            $query->execute();
            $flag = 1;
        } catch (PDOException $e) {
            die($e->getMessage());
        }
        if ($flag == 1) {
            return true;
        } else {
            echo "not inserted";
            return false;
        }
    } else {
        return false;
    }
}
开发者ID:apoorv30gupta,项目名称:Hablar-1,代码行数:29,代码来源:ChatFunctions.php

示例3: cs_price

function cs_price($itemName)
{
    $col = db_init('market_730', 'item_prices');
    //old query that worked: array( array( '$match' => array( 'name' =>$itemName ) ), array( '$group' => array( '_id'=>null,  'avgPrice' => array( '$avg'=> '$price' ) ) ) );
    $count = $col->count(array("name" => "{$itemName}"));
    if ($count == 0) {
        //$res = json_decode( get_data( 'http://steamcommunity.com/market/priceoverview/?appid=730&market_hash_name=' . urlencode( $itemName ) ), true );
        //if(isset($res['success'] ) && $res['success'] == true && (isset($res['lowest_price']) || isset($res['median_price']) ) ){
        // if (isset($res['median_price']))
        //  return substr($res['median_price'], 1);
        // if (isset($res['lowest_price']))
        //  return substr($res['lowest_price'], 1);
        //}
        return -1;
    }
    $item = $col->find(array("name" => "{$itemName}"))->sort(array("price" => 1))->skip($count / 2 - 1)->limit(1);
    $a = iterator_to_array($item);
    foreach ($a as $a) {
        return $a['price'];
    }
    //$query = array( 'name' =>$itemName );
    //$price = $col -> find( $query );
    //if ( isset( $price['result'][0]['avgPrice'] ) )
    //  $avgPrice = $price['result'][0]['avgPrice'];
    //else $avgPrice = 0;
    //return $avgPrice;
}
开发者ID:aaronsnow123,项目名称:OpenEndgame,代码行数:27,代码来源:csgolist.php

示例4: show_graph

function show_graph()
{
    require_once "../inc/db.inc";
    db_init();
    $xaxis = $_GET['xaxis'];
    $yaxis = $_GET['yaxis'];
    $granularity = $_GET['granularity'];
    $active = $_GET['active'];
    $inactive = $_GET['inactive'];
    $show_text = $_GET['show_text'];
    if (!$active && !$inactive) {
        echo "You must select at least one of (active, inactive)";
        exit;
    }
    $fields = 'host.id, user.create_time';
    if ($xaxis == 'active' || !$active || !$inactive) {
        $query = "select {$fields}, max(rpc_time) as max_rpc_time from host, user where host.userid=user.id group by userid";
    } else {
        $query = 'select $fields from user';
    }
    $result = mysql_query($query);
    $yarr = array();
    $now = time();
    $maxind = 0;
    $active_thresh = time() - 30 * 86400;
    while ($user = mysql_fetch_object($result)) {
        $val = $now - $user->max_rpc_time;
        if (!$active) {
            if ($user->max_rpc_time > $active_thresh) {
                continue;
            }
        }
        if (!$inactive) {
            if ($user->max_rpc_time < $active_thresh) {
                continue;
            }
        }
        $life = $user->max_rpc_time - $user->create_time;
        $ind = $life / $granularity;
        $ind = (int) $ind;
        $yarr[$ind]++;
        if ($ind > $maxind) {
            $maxind = $ind;
        }
    }
    $xarr = array();
    for ($i = 0; $i <= $maxind; $i++) {
        $xarr[$i] = $i;
        if (is_null($yarr[$i])) {
            $yarr[$i] = 0;
        }
    }
    if ($show_text) {
        show_text($xarr, $yarr);
    } else {
        draw_graph($xarr, $yarr);
    }
}
开发者ID:Turante,项目名称:boincweb,代码行数:58,代码来源:user_graph.php

示例5: user_name

/**
	Get username based on user id
	id = user id
**/
function user_name($id)
{
    $CI = db_init();
    $query = "SELECT username FROM flx_user WHERE id='{$id}' LIMIT 1";
    $record = $CI->db->query($query);
    if ($record->num_rows() > 0) {
        return $record->row()->username;
    } else {
        return false;
    }
}
开发者ID:adrianha,项目名称:Rafa-Server,代码行数:15,代码来源:kernel_helper.php

示例6: index

 function index()
 {
     if (is_installed()) {
         return info_page(__('INSTALL_FINISHED'));
     } elseif (intval(v('do')) == 1) {
         db_init();
     } else {
         $data['title'] = $data['top_title'] = __('INSTALL_PAGE_TITLE');
         return render($data, 'web', 'fullwidth');
     }
 }
开发者ID:wangkf,项目名称:TeamToy,代码行数:11,代码来源:install.class.php

示例7: index

 function index()
 {
     if (is_installed()) {
         return info_page('API Server 已初始化完成,<a href="?c=guest">请使用管理账号登入</a>');
     } elseif (intval(v('do')) == 1) {
         db_init();
     } else {
         $data['title'] = $data['top_title'] = 'TeamToy安装页面';
         return render($data, 'web', 'fullwidth');
     }
 }
开发者ID:ramo01,项目名称:1kapp,代码行数:11,代码来源:install.class.php

示例8: util_initEverything

function util_initEverything()
{
    // smarty < session_start/end : smarty caches the person's nickname.
    util_defineRootPath();
    util_defineWwwRoot();
    util_requireOtherFiles();
    util_defineConstants();
    db_init();
    session_init();
    mc_init();
    FlashMessage::restoreFromSession();
    SmartyWrap::init();
    DebugInfo::init();
}
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:14,代码来源:util.php

示例9: util_initEverything

function util_initEverything()
{
    // smarty < session_start/end : smarty caches the person's nickname.
    util_defineRootPath();
    util_defineWwwRoot();
    // At this point the server preferences are loaded (when
    // util_requireOtherFiles() includes serverPreferences.php)
    util_requireOtherFiles();
    util_defineConstants();
    db_init();
    session_init();
    mc_init();
    FlashMessage::restoreFromSession();
    smarty_init();
}
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:15,代码来源:util.php

示例10: bug_submit

function bug_submit($bug_type, $bug_text)
{
    if (!is_numeric($bug_type) && $bug_type >= 2 && $bug_type <= 5) {
        echo 'invalid bug type, report not submitted.';
        return 0;
    }
    if (!isset($_SESSION['sid'])) {
        echo 'Not logged in, try again.';
        return 0;
    }
    $bug_text = (string) substr(htmlentities($bug_text), 0, 1000);
    $c = db_init('site_data', 'bugs');
    $c->insert(array('sid' => (int) $_SESSION['sid'], 'bug_type' => (int) $bug_type, 'bug_text' => $bug_text));
    echo '<h3>Report Submitted Successfully.</h3>';
}
开发者ID:aaronsnow123,项目名称:OpenEndgame,代码行数:15,代码来源:bug.php

示例11: s2lbm

 function s2lbm($file)
 {
     global $config;
     $this->sql = db_init($config['sql']);
     $this->palette = new s2pal("");
     if (is_file($file)) {
         $this->hash = md5_file($file);
         $this->file = $file;
         $f = pathinfo($file);
         switch (strtolower($f['extension'])) {
             case 'lbm':
                 $this->_loadLBM($file);
                 break;
         }
     }
     echo $this->get_error();
 }
开发者ID:Return-To-The-Roots,项目名称:s2map-php,代码行数:17,代码来源:s2lbm.php

示例12: DISPLAY_show_torrent

function DISPLAY_show_torrent($torrent)
{
    if (!($link = db_init(true))) {
        break;
    }
    $result = mysqli_query($link, 'SELECT * FROM `users` WHERE `id`=' . mysqli_real_escape_string($link, $torrent['uploader']) . ';');
    $uploader = @mysqli_fetch_all($result, MYSQLI_ASSOC)[0];
    $uploader = is_array($uploader) ? $uploader['username'] : 'Deleted user';
    mysqli_free_result($result);
    mysqli_close($link);
    unset($link);
    echo '<tr>';
    echo '<td><a href="info.php?id=' . $torrent['id'] . '"><b>' . $torrent['torrentname'] . '</b></a></td>';
    echo '<td><a href="user.php?id=' . $torrent['uploader'] . '"><i>' . $uploader . '</a></i></td>';
    echo '<td>' . getHumanDate(new DateTime($torrent['created']), new DateTime(date('Y-n-d H:i:s', time()))) . '</td>';
    echo '<td>' . getHumanFilesize(getTorrent(unserialize(_CONFIG)['torrents']['dir'] . DIRECTORY_SEPARATOR . $torrent['filename'] . '.torrent')->size()) . '</td>';
    echo '<td>' . $torrent['downloads'] . '</td>';
    echo '<td><font color="green">TBD</font></td>';
    echo '<td><font color="blue">TBD</font></td>';
    echo '</tr>';
}
开发者ID:nickyschlobs,项目名称:atlas,代码行数:21,代码来源:functions.php

示例13: get_100_users

function get_100_users()
{
    $c = db_init('archive', 'items_730');
    $OOD = $c->find(array("recent" => array('$lt' => time() - 172800)), array('_id' => 1))->sort(array("recent" => 1))->limit(100);
    //get a list of the most out of date steamids in the database (returns steamids only)
    $sids = '';
    if ($OOD->count() > 100) {
        $is_additive = false;
        foreach ($OOD as $k => $usr) {
            $sids .= ',' . $usr['_id'];
        }
    } else {
        $steamid1 = db_load('start_steamid_730');
        if (empty($steamid1)) {
            $steamid1 = 76561197960287930;
        }
        $sc = 0;
        while ($sc <= 100 && $sc++) {
            $sids .= ',' . ($steamid1 + $sc);
        }
    }
    $playerData = json_decode(get_data('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . AKey() . '&steamids=' . $sids . '&format=json'), true);
    return $playerData['response']['players'];
}
开发者ID:aaronsnow123,项目名称:OpenEndgame,代码行数:24,代码来源:update_730.php

示例14: intval

}
$PlayerCount = intval($con->real_escape_string($_REQUEST["playercount"]));
$TTL = max(min(intval($con->real_escape_string($_REQUEST["ttl"])), $MAX_TTL), 1);
$Rev = $con->real_escape_string($_REQUEST["rev"]);
if (!CheckVersion($Rev)) {
    $con->close();
    die("Invalid revision");
}
$Coderev = $con->real_escape_string($_REQUEST["coderev"]);
$IsDedicated = intval($con->real_escape_string($_REQUEST["dedicated"]));
$OS = $con->real_escape_string($_REQUEST["os"]);
if ($Name === "" || $IP === "" || $Port === "" || $TTL === "" || $PlayerCount === "") {
    error_log("Incorrect parameters " . $Name . " " . $IP . " " . $Port . " " . $TTL . " " . $PlayerCount . " ");
    $con->close();
    die("Incorrect parameters");
}
//Don't allow buggy Linux server versions, Windows server (ICS) is ok
if (($Coderev == "r4179" || $Coderev == "r4185") && $_SERVER['HTTP_USER_AGENT'] != "Mozilla/4.0 (compatible; ICS)") {
    $con->close();
    die("Please download the server update");
}
$Pingable = intval(TestConnection($IP, $Port));
db_init($con);
Remove_Old_Servers($con);
$Expiry = date("Y-m-d H:i:s", time() + $TTL);
$query = "REPLACE INTO Servers (IP, Port, Name, Players, Pingable, Dedicated, OS, Rev, CodeRev, Expiry) VALUES ('{$IP}', {$Port}, '{$Name}', {$PlayerCount}, {$Pingable}, {$IsDedicated}, '{$OS}', '{$Rev}', '{$Coderev}', '{$Expiry}')";
if (!$con->query($query)) {
    error_log("Error adding server: " . mysqli_error($con));
}
$con->close();
die('success');
开发者ID:leyyin,项目名称:kam_remake,代码行数:31,代码来源:serveradd.php

示例15: print_info

<?php

include_once 'remora/settings.php';
include_once 'remora/lib.php';

print_info("Installing Remora Version ".VERSION);

// Establish a db connection
$conn = db_init();

print_info("Installation completed successfully");

?>
开发者ID:rmillsap,项目名称:remora,代码行数:13,代码来源:install.php


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