本文整理汇总了PHP中DBLayer::fetch_assoc方法的典型用法代码示例。如果您正苦于以下问题:PHP DBLayer::fetch_assoc方法的具体用法?PHP DBLayer::fetch_assoc怎么用?PHP DBLayer::fetch_assoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBLayer
的用法示例。
在下文中一共展示了DBLayer::fetch_assoc方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isKnownUser
function isKnownUser($username, $userpass = null)
{
global $db, $CNF;
// echo $username;
if (strlen($username) > 0) {
$db = new DBLayer($CNF["db_host"], $CNF["db_user"], $CNF["db_pass"], $CNF["db_name"]);
$db->query("SET NAMES utf8");
$sql_pass = $userpass != null ? "`status_id` !=4 AND `pass`='{$userpass}'" : '`status_id` !=4';
$query = $db->query("SELECT `uid`,`login`,`lastname`,`firstname`,`middlename` FROM users WHERE `login`='{$username}' AND {$sql_pass}");
if ($db->num_rows($query) > 0) {
$auth = $db->fetch_assoc($query);
return $auth;
}
}
return false;
}
示例2: isset
$arr[$i]['cl'] = $result['class'];
$arr[$i]['race'] = $result['race'];
$arr[$i]['level'] = $char_data[$UNIT_FIELD_LEVEL];
$arr[$i]['gender'] = $char_gender[3];
$arr[$i]['Extention'] = $Extention;
$arr[$i]['leaderGuid'] = isset($groups[$char_data[0]]) ? $groups[$char_data[0]] : 0;
$i++;
}
$mangos_db->close();
usort($arr, "sort_players");
$arr = array_merge($Count, $arr);
$res['online'] = $arr;
} else {
$res['online'] = NULL;
}
if ($show_status) {
$mangos_db = new DBLayer($mangos[$royaume]['host'], $mangos[$royaume]['user'], $mangos[$royaume]['password'], $mangos[$royaume]['db']);
$mangos_db->query("SET NAMES " . $mangos[$royaume]['encoding'] . "");
$query = $mangos_db->query("SELECT `starttime`,`maxplayers` FROM `uptime` WHERE `starttime`=(SELECT MAX(`starttime`) FROM `uptime`)");
if ($result = $mangos_db->fetch_assoc($query)) {
$status['uptime'] = time() - $result['starttime'];
$status['maxplayers'] = $result['maxplayers'];
$status['online'] = test_realm() ? 1 : 0;
}
$mangos_db->close();
} else {
$status = NULL;
}
unset($mangos_db);
$res['status'] = $status;
$_RESULT = $res;
示例3: DBLayer
$lang = $language;
}
$database_encoding = $site_encoding;
$server = $server_arr[$realm_id]["addr"];
$port = $server_arr[$realm_id]["game_port"];
$host = $characters_db[$realm_id]["addr"];
$user = $characters_db[$realm_id]["user"];
$password = $characters_db[$realm_id]["pass"];
$db = $characters_db[$realm_id]["name"];
$hostr = $realm_db["addr"];
$userr = $realm_db["user"];
$passwordr = $realm_db["pass"];
$dbr = $realm_db["name"];
$sql = new DBLayer($hostr, $userr, $passwordr, $dbr);
$query = $sql->query("SELECT name FROM realmlist WHERE id = " . $realm_id);
$realm_name = $sql->fetch_assoc($query);
$realm_name = htmlentities($realm_name["name"]);
$gm_show_online = $gm_online;
$gm_show_online_only_gmoff = $map_gm_show_online_only_gmoff;
$gm_show_online_only_gmvisible = $map_gm_show_online_only_gmvisible;
$gm_add_suffix = $map_gm_add_suffix;
$gm_include_online = $gm_online_count;
$show_status = $map_show_status;
$time_to_show_uptime = $map_time_to_show_uptime;
$time_to_show_maxonline = $map_time_to_show_maxonline;
$time_to_show_gmonline = $map_time_to_show_gmonline;
$status_gm_include_all = $map_status_gm_include_all;
$time = $map_time;
$show_time = $map_show_time;
// points located on these maps(do not modify it)
$maps_for_points = "0,1,530,571,609";
示例4: explode
$query = $logon_db_PM->query("SELECT GROUP_CONCAT(`acct` SEPARATOR ' ') FROM `accounts` WHERE `gm`<>'0'");
if ($query) {
if ($result = $logon_db_PM->fetch_row($query)) {
$gm_accounts = explode(' ', $result[0]);
}
}
$groups = array();
$characters_db_PM = new DBLayer($host, $user, $password, $db);
if (!$characters_db_PM->isValid()) {
$_RESULT['status']['online'] = 2;
exit;
}
$characters_db_PM->query("SET NAMES {$database_encoding}");
$query = $characters_db_PM->query("SELECT `leaderGuid`,`memberGuid` FROM `group_member` WHERE `memberGuid` IN(SELECT `guid` FROM `characters` WHERE `online`='1')");
if ($query) {
while ($result = $characters_db_PM->fetch_assoc($query)) {
$groups[$result['memberGuid']] = $result['leaderGuid'];
}
}
$Count = array();
for ($i = 0; $i < $maps_count; $i++) {
$Count[$i] = array(0, 0);
}
$arr = array();
$i = $maps_count;
$query = $characters_db_PM->query("SELECT `acct`,`data`,`name`,`class`,`race`, `level`, `gender`, `positionx`,`positiony`,`mapid`,`zoneid`,`player_flags` FROM `characters` WHERE `online`={$map_show_online} ORDER BY `name`");
while ($result = $characters_db_PM->fetch_assoc($query)) {
if ($result['mapid'] == 530 && $result['positiony'] > -1000 || in_array($result['mapid'], $outland_inst)) {
$Extention = 1;
} else {
if ($result['mapid'] == 571 || in_array($result['mapid'], $northrend_inst)) {
示例5: error
break;
default:
error(sprintf($lang_install['No such database type'], forum_htmlencode($db_type)));
}
// Create the database object (and connect/select db)
$forum_db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false);
// If MySQL, make sure it's at least 4.1.2
if (in_array($db_type, array('mysql', 'mysqli', 'mysql_innodb', 'mysqli_innodb'))) {
$mysql_info = $forum_db->get_version();
if (version_compare($mysql_info['version'], MIN_MYSQL_VERSION, '<')) {
error(sprintf($lang_install['Invalid MySQL version'], forum_htmlencode($mysql_info['version']), MIN_MYSQL_VERSION));
}
// Check InnoDB support in DB
if (in_array($db_type, array('mysql_innodb', 'mysqli_innodb'))) {
$result = $forum_db->query('SHOW VARIABLES LIKE \'have_innodb\'');
$row = $forum_db->fetch_assoc($result);
if (!$row || !isset($row['Value']) || strtolower($row['Value']) != 'yes') {
error($lang_install['MySQL InnoDB Not Supported']);
}
}
}
// Validate prefix
if (strlen($db_prefix) > 0 && (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $db_prefix) || strlen($db_prefix) > 40)) {
error(sprintf($lang_install['Invalid table prefix'], $db_prefix));
}
// Check SQLite prefix collision
if (in_array($db_type, array('sqlite', 'sqlite3')) && strtolower($db_prefix) == 'sqlite_') {
error($lang_install['SQLite prefix collision']);
}
// Make sure PunBB isn't already installed
if ($forum_db->table_exists('users')) {
示例6: DBLayer
function get_character_honor($char_id)
{
global $hostr, $userr, $passwordr, $db, $dbr, $dbc, $database_encoding;
$mangos_db = new DBLayer($hostr, $userr, $passwordr, $dbc);
$query = $mangos_db->query("SELECT * FROM `character_kill` WHERE `guid`='{$char_id}'");
while ($res_row = $mangos_db->fetch_assoc($query)) {
$honor += $res_row['honor'];
}
$mangos_db->close();
return $honor;
}
示例7: DBLayer
<?php
require "subs.php";
require_once "conf.inc.php";
require_once "lib/dblayer.php";
$btn_home = "<a class='button' href='./'><<</a>";
$db = new DBLayer($CNF["db_host"], $CNF["db_user"], $CNF["db_pass"], $CNF["db_name"]);
$db->query("SET NAMES utf8");
$q = "SELECT\n u.`uid`,\n u.`modiff`,\n DATE_FORMAT(u.`modiff`,'%d.%m.%Y %H:%i:%s') AS `modiff_fmt`,\n (SELECT CONCAT(`lastname`,' ',`firstname`) FROM users WHERE `uid`=u.`modiff_uid`) AS `modiff_uid`,\n u.`status_id`,\n u.`lastname`,\n u.`firstname`,\n u.`middlename`,\n u.`login`,\n u.`pass`\n FROM users AS u ORDER BY `uid` DESC LIMIT 5";
if ($qry = $db->query($q)) {
eval(tmplt_gen("stat/forms/begin.form"));
eval(tmplt_gen("users/forms/filter.form"));
while ($res = $db->fetch_assoc($qry)) {
$page .= table_users($res);
}
$page .= "</table>";
$page .= "<div class='table-footer'><span class='statusbar'> </span>";
} else {
echo 'error';
}
//print_r($res);
echo $page;
$db_err = $db->error();
$db->close();
if ($db_err["error_no"] != null) {
print_r($db_err);
}
// DB-errors
示例8: isset
require "lib/dblayer.php";
$stage = isset($_REQUEST["stage"]) ? check_string($_REQUEST["stage"], "string") : null;
// Стадия
// Авторизация
global $CNF;
//echo $stage;
if ($stage == "auth") {
$db = new DBLayer($CNF["db_host"], $CNF["db_user"], $CNF["db_pass"], $CNF["db_name"]);
$db->query("SET NAMES utf8");
$login = check_string($_REQUEST["login"], "string");
$pass_hash = md5($_REQUEST["pass"]);
// echo "SELECT `uid` FROM users WHERE `login`='$login' AND `pass_hash`='$pass_hash'";
$query_auth = $db->query("SELECT `uid` FROM users WHERE `login`='{$login}' AND `pass_hash`='{$pass_hash}'");
$db->num_rows($query_auth);
if ($query_auth and $db->num_rows($query_auth) == 1) {
$admin_login = $db->fetch_assoc($query_auth);
// $hash = md5(microtime()); // Случайная строка-хеш (32-символа)
// $db -> query("UPDATE admins SET `hash`='".$hash."' WHERE `uid`='".$admin_login['uid']."'"); // Запись хеша в БД
# Печеньки:
$cookie_lifetime = isset($_REQUEST["remember"]) == "on" ? strtotime("+1 year") : 0;
// Время жизни: 1 год или 0 - до закрытия броузера
setcookie("user_id", $admin_login['uid'], $cookie_lifetime);
setcookie("hash", $pass_hash, $cookie_lifetime);
unset($stage, $_POST["name"], $_POST["pass"], $_REQUEST["stage"]);
header("Location: http://" . $_SERVER["HTTP_HOST"] . "/" . check_string($_SESSION["ref"], "string"));
} else {
$msg = "<div class='msg error'>Неверный логин или пароль</div>";
include "stat/forms/login.form";
}
$db_err = $db->error();
$db->close();
示例9: DBLayer
//DBlayers switched table, so $db must be re-introduced
$db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false);
while ($row = $imp->fetch_assoc($cat_query)) {
$query = array('INSERT' => 'title, description, active, father_id, old_id, old_id_backup', 'INTO' => 'categories', 'VALUES' => '"' . $row['title'] . '", "' . $row['description'] . '", 1, "' . $row['ref'] . '", "' . $row['id'] . '", "' . $row['id'] . '"');
$db->query_build($query) or error(__FILE__, __LINE__);
}
while ($lrow = $imp->fetch_assoc($link_query)) {
$query = array('SELECT' => 'id', 'FROM' => 'categories', 'WHERE' => 'old_id=' . $lrow['ref']);
$new_cat_id = $db->query_build($query) or error(__FILE__, __LINE__);
$new_cat_id = $db->fetch_row($new_cat_id);
$query = array('INSERT' => 'title, url, description, active, category_id, ip, type, payment_status, old_category_id_backup', 'INTO' => 'links', 'VALUES' => '"' . $lrow['title'] . '", "' . $lrow['url'] . '", "' . $lrow['description'] . '", ' . ($lrow['accepted'] == 'y' ? 1 : 0) . ', ' . $new_cat_id[0] . ', "' . $lrow['ip'] . '", "a", "ok", ' . $lrow['category']);
$db->query_build($query) or error(__FILE__, __LINE__);
}
//re-sort father_ids
$query = array('UPDATE' => 'categories', 'SET' => 'father_id=' . intval($_POST['category_id']), 'WHERE' => 'father_id=0 AND old_id<>0');
$db->query_build($query) or error(__FILE__, __LINE__);
$query = array('SELECT' => 'id, father_id, old_id', 'FROM' => 'categories', 'WHERE' => 'father_id <> ' . intval($_POST['category_id']) . ' AND old_id<>0 ORDER BY father_id ASC');
$sql_resort = $db->query_build($query) or error(__FILE__, __LINE__);
while ($res = $db->fetch_assoc($sql_resort)) {
$query = array('SELECT' => 'id', 'FROM' => 'categories', 'WHERE' => 'old_id=' . $res['father_id']);
$get_id = $db->query_build($query) or error(__FILE__, __LINE__);
$get_id = $db->fetch_row($get_id);
$query = array('UPDATE' => 'categories', 'SET' => 'father_id=' . intval($get_id[0]), 'WHERE' => 'id=' . $res['id']);
$db->query_build($query) or error(__FILE__, __LINE__);
}
$imp_result = "Links and categories have now been imported from Free PHP Directory Script";
} else {
$imp_result = "Script '" . $_POST['directory_script'] . "' is not supported";
}
$db->drop_field('categories', 'old_id');
}