本文整理汇总了PHP中DB::fetch_array方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::fetch_array方法的具体用法?PHP DB::fetch_array怎么用?PHP DB::fetch_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::fetch_array方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* 获取查询结果
*
* @access protected
* @param resource $query 数据库结果集资源符
* @param string|null 数据结果数组的索引key,为null则为自增key
* @return array
*/
function _getAllResultFromQuery($query, $resultIndexKey = null)
{
$result = array();
if ($resultIndexKey) {
while ($rt = $this->_db->fetch_array($query)) {
$result[$rt[$resultIndexKey]] = $rt;
}
} else {
while ($rt = $this->_db->fetch_array($query)) {
$result[] = $rt;
}
}
return $result;
}
示例2: doindex
public function doindex()
{
global $_M;
$jsrand = str_replace('.', '', $_M[config][metcms_v]) . $_M[config][met_patch];
if ($_M['config']['met_agents_type'] >= 2) {
$met_admin_logo = "{$_M[url][site]}" . str_replace('../', '', $_M['config']['met_agents_logo_index']);
$query = "SELECT * FROM {$_M['table']['config']} WHERE lang='{$_M['langset']}-metinfo'";
$result = DB::query($query);
while ($list_config = DB::fetch_array($result)) {
$lang_agents[$list_config['name']] = $list_config['value'];
}
$_M['word']['metinfo'] = $lang_agents['met_agents_name'];
}
//
$toparr = get_adminnav();
if ($_M['config']['met_agents_type'] >= 2) {
$met_admin_logo = "{$_M[url][site]}" . str_replace('../', '', $_M['config']['met_agents_logo_index']);
$query = "SELECT * FROM {$_M['table']['config']} WHERE lang='{$_M['langset']}-metinfo'";
$result = DB::query($query);
while ($list_config = DB::fetch_array($result)) {
$lang_agents[$list_config['name']] = $list_config['value'];
}
$_M['word']['indexthanks'] = $lang_agents['met_agents_thanks'];
$_M['word']['metinfo'] = $lang_agents['met_agents_name'];
$_M['word']['copyright'] = $lang_agents['met_agents_copyright'];
$_M['word']['oginmetinfo'] = $lang_agents['met_agents_depict_login'];
$met_agents_display = "style=\"display:none\"";
} else {
$met_admin_logo = "{$_M[url][ui]}images/logo.png";
}
//
require $this->template('tem/index');
}
示例3: login
public function login($login, $pass)
{
//echo "construct " . $this->name[0];
if (!isset($_COOKIE['auth'])) {
$db = new DB();
$sql = "SELECT *\n FROM users\n WHERE username = '" . $login . "'";
$result = $db->query($sql);
if ($row = $db->fetch_array($result)) {
if ($row['password'] == md5($pass)) {
$this->name = $login;
$this->id = $row['id'];
setcookie('user_id', $row['id']);
setcookie('auth', md5(time()));
setcookie('name', $this->name);
} else {
die('error login');
}
} else {
die('login error');
}
} else {
$this->name = $_COOKIE['name'];
$this->id = $_COOKIE['user_id'];
}
return $this->name;
}
示例4: getAdverBenchs
function getAdverBenchs()
{
$benchs = array();
$query = $this->_db->query("SELECT * FROM pw_advert WHERE type=0");
while ($rs = $this->_db->fetch_array($query)) {
list($title) = explode("~\t~", $rs['descrip']);
$benchs[$rs['ckey']] = $title;
}
return $benchs;
}
示例5: allUsers
public static function allUsers()
{
$db = new DB();
$sql = "SELECT *\n FROM users";
$result = $db->query($sql);
while ($row = $db->fetch_array($result)) {
$users[] = ['id' => $row['id'], 'username' => $row['username']];
}
return $users;
}
示例6: synlogin
function synlogin($user)
{
list($winduid, $windid, $windpwd) = explode("\t", $this->base->strcode($user, false));
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
include ROOT_PATH . 'include/func/global.func.php';
DB::query("SELECT `uid`, `password` FROM `" . DB::table('members') . "` WHERE `ucuid`='{$winduid}'");
$UserFields = DB::fetch_array($query);
if ($UserFields) {
$auth = authcode("{$UserFields['password']}\t{$UserFields['uid']}", "ENCODE", '', 1209600);
jsg_setcookie('sid', '', -311040000);
jsg_setcookie('auth', $auth, 311040000);
}
}
示例7: testFetchArray
public function testFetchArray()
{
$db = new DB();
$host = "localhost";
$user = "root";
$pass = "";
$db_name = "thankscard";
$db->db_connect($host, $user, $pass, $db_name);
$sql = "SELECT * FROM user ";
$rs = $db->db_query($sql);
$user = $db->fetch_array($rs);
print_r($user);
echo 123;
}
示例8: load_agent_word
/**
* 代理商配置语言修改
*/
protected function load_agent_word($lang)
{
global $_M;
if ($_M['config']['met_agents_type'] >= 2) {
$query = "SELECT * FROM {$_M['table']['config']} WHERE lang='{$lang}-metinfo'";
$result = DB::query($query);
while ($list_config = DB::fetch_array($result)) {
$lang_agents[$list_config['name']] = $list_config['value'];
}
$_M['word']['indexthanks'] = $lang_agents['met_agents_thanks'];
$_M['word']['metinfo'] = $lang_agents['met_agents_name'];
$_M['word']['copyright'] = $lang_agents['met_agents_copyright'];
$_M['word']['oginmetinfo'] = $lang_agents['met_agents_depict_login'];
}
}
示例9: get_group_list
public function get_group_list()
{
global $_M;
if (!$this->grouplist[$this->lang]) {
$this->grouplist[$this->lang] = cache::get("user/grouplist_{$this->lang}");
if (!$this->grouplist[$this->lang]) {
$query = "SELECT * FROM {$_M['table']['user_group']} WHERE lang='{$this->lang}' order by access ASC";
$result = DB::query($query);
while ($list = DB::fetch_array($result)) {
$this->grouplist[$this->lang][$list['id']] = $list;
}
cache::put("user/grouplist_{$this->lang}", $this->grouplist[$this->lang]);
}
}
return $this->grouplist[$this->lang];
}
示例10: get_outapp
public function get_outapp()
{
global $_M;
$query = "SELECT * FROM {$_M['table']['app']} WHERE download=1 ORDER BY id DESC";
$result = DB::query($query);
while ($list = DB::fetch_array($result)) {
if (!$this->have_power($list['no'])) {
continue;
}
$list = $this->standard($list);
$app[$list[no]] = $list;
}
$query = "SELECT * FROM {$_M['table']['applist']} WHERE m_name != '' ORDER BY id DESC";
$result = DB::query($query);
while ($list = DB::fetch_array($result)) {
$list = $this->standard($list);
$app[$list['no']] = $list;
}
return $app;
}
示例11: dirname
<?php
require_once dirname(__FILE__) . "/library/DB.php";
require_once dirname(__FILE__) . "/config/config.php";
session_start();
$db = new DB();
$db->db_connect();
if (isset($_SESSION["user"])) {
header("Location: list.php");
}
if (isset($_POST["eid"])) {
$sql = "SELECT * FROM user WHERE (user_eid = '" . $db->db_escape_string($_POST["eid"]) . "' OR LOWER(user_nick_name) = LOWER('" . $db->db_escape_string($_POST["eid"]) . "')) AND active = 1";
$rs = $db->db_query($sql);
$user = $db->fetch_array($rs);
if (!$user) {
$errors = "EID not exist";
} else {
$_SESSION["user"] = $user;
header("Location: list.php");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="/bower_components/Materialize/dist/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Let browser know website is optimized for mobile-->
</head>
示例12: get_para_list
public function get_para_list($module, $class1, $class2, $class3)
{
global $_M;
if (!$this->paralist[$module][$this->lang]) {
$this->paralist[$module][$this->lang] = cache::get("para/paralist_{$module}_{$this->lang}");
if (!$this->paralist[$module][$this->lang]) {
$query = "SELECT * FROM {$_M['table']['parameter']} WHERE module='{$module}' and lang='{$_M['lang']}' order by no_order ASC, id ASC";
$result = DB::query($query);
while ($list = DB::fetch_array($result)) {
if ($list['options']) {
$lists = explode("\$|\$", $list['options']);
$list['list'] = $lists;
}
$this->paralist[$module][$this->lang][$list['id']] = $list;
}
cache::put("para/paralist_{$module}_{$this->lang}", $this->paralist[$module][$this->lang]);
}
}
$re = $this->paralist[$module][$this->lang];
$paralists = array();
foreach ($re as $val) {
if ($val['class1']) {
if ($val['class1'] == $class1) {
if ($val['class2'] == 0 && $val['class3'] == 0) {
$paralists[] = $val;
}
if ($val['class2'] && $val['class2'] == $class2 && $val['class3'] == 0) {
$paralists[] = $val;
}
if ($val['class3'] && $val['class3'] == $class3) {
$paralists[] = $val;
}
}
} else {
$paralists[] = $val;
}
}
$re = $paralists;
return $re;
}
示例13: MessageSend
$result = $db->fetch_assoc($db->execute("SELECT * FROM `news` WHERE `id` = '{$id}'"));
$db->close();
if (empty($result['id'])) {
MessageSend(1, 'Новость не найдена!');
}
$title = $result['title'];
ob_start();
include SITE_ROOT . 'style/news/full.html';
$content_main = ob_get_clean();
} else {
$title = 'Новости';
$menu_id = 'main';
$news_on_page = 6;
$db = new DB();
$db->connect();
$news_count = $db->fetch_array($db->execute("SELECT COUNT(id) FROM `news`"));
$total = ceil($news_count[0] / $news_on_page);
if (empty($_GET['p'])) {
$_GET['p'] = '1';
}
$p = $_GET['p'];
$p = TextSave($p);
if (!ctype_digit($p) or $p > $total) {
$p = "1";
}
// формируем запрос
$first = $p * $news_on_page - $news_on_page;
$result = $db->execute("SELECT * FROM `news` ORDER BY `id` DESC LIMIT {$first}, {$news_on_page}");
ob_start();
include SITE_ROOT . 'style/news/news_list.html';
$content_main = ob_get_clean();
示例14: exit
$db->connect();
$Row = $db->fetch_assoc($db->execute("SELECT * FROM `pm` WHERE `id` = {$id}"));
if (empty($Row['id']) or $Row['reciver'] != $player['id']) {
$db->close();
exit(header("Location: /pm/"));
}
$db->execute("UPDATE `pm` SET `readed` = '2' WHERE `id` = '{$id}'");
$db->close();
ob_start();
include SITE_ROOT . 'style/pm/see.html';
$content_main = ob_get_clean();
} else {
$pm_on_page = 10;
$db = new DB();
$db->connect();
$pm_count = $db->fetch_array($db->execute("SELECT COUNT(id) FROM `pm`"));
$total = ceil($pm_count[0] / $pm_on_page);
if (empty($_GET['p'])) {
$_GET['p'] = '1';
}
$p = $_GET['p'];
$p = TextSave($p);
if (!ctype_digit($p) or $p > $total) {
$p = "1";
}
// формируем запрос
$first = $p * $pm_on_page - $pm_on_page;
$result = $db->execute("SELECT * FROM `pm` WHERE `reciver` = '" . $player['id'] . "' ORDER BY `id` DESC LIMIT {$first}, {$pm_on_page}");
$db->close();
ob_start();
include SITE_ROOT . 'style/pm/list.html';
示例15: glpiuImportPrinters
function glpiuImportPrinters($mode, $start = 0)
{
global $PRINTERSLIST, $UC_OCSIDS, $UC_NAMES, $CFG_GLPI, $LANG;
$DBocs = new DBocs($_SESSION["ocsservers_id"]);
$DB = new DB();
$noPort = 0;
$numrows = 0;
$UC_OCSIDS = array();
// Correspondance UC ocs/glpi
// Recherche les ports
$query_ports = "select distinct hardware.NAME as UC_Name, hardware.DEVICEID, printers.NAME, printers.PORT, printers.DRIVER from printers " . "inner join hardware on hardware.ID = printers.HARDWARE_ID where printers.DRIVER <> '' order by hardware.DEVICEID, printers.NAME, printers.PORT, printers.DRIVER";
$result_ports = $DBocs->query($query_ports) or die($DBocs->error());
if ($DBocs->numrows($result_ports) > 0) {
// Récupère les UC dans GLPI
$query_UC = "select distinct glpi_id, ocs_id from glpi_ocs_link order by glpi_id";
$result_UC = $DB->query($query_UC) or die($DB->error());
if ($DB->numrows($result_UC) > 0) {
while ($data = $DB->fetch_array($result_UC)) {
$UC_OCSIDS[$data["ocs_id"]] = array('glpi_id' => $data["glpi_id"], 'UC_Name' => '', 'driver' => '');
}
}
unset($result_UC);
// Recherche les UC liés à une imprimante dans OCS
$query_UC = "select distinct hardware.NAME as UC_Name, hardware.ID as ocs_id from hardware " . "inner join printers on printers.HARDWARE_ID = hardware.ID order by hardware.DEVICEID, hardware.NAME";
$result_UC = $DBocs->query($query_UC) or die($DBocs->error());
if ($DBocs->numrows($result_UC) > 0) {
while ($data = $DBocs->fetch_array($result_UC)) {
if (array_key_exists($data["ocs_id"], $UC_OCSIDS)) {
$UC_OCSIDS[$data["ocs_id"]]['UC_Name'] = strtoupper($data["UC_Name"]);
}
}
}
unset($result_UC);
// Suppression des UC sans imprimante
// création d'une table des UC avec nom pour clé
foreach ($UC_OCSIDS as $ocs_id => &$item) {
if ($item['UC_Name'] === '') {
unset($UC_OCSIDS[$ocs_id]);
} else {
$UC_NAMES[$item['UC_Name']] = array('glpi_id' => $item["glpi_id"], 'ocs_id' => $ocs_id);
}
}
unset($UC_OCSIDS);
// Création des imprimantes
while ($data = $DBocs->fetch_array($result_ports)) {
glpiuInsertPrinter($data["PORT"], $data["NAME"], $data["UC_Name"], $data["DRIVER"]);
}
unset($result_ports);
unset($UC_NAMES);
// Si en mode action, suppression des imprimantes
/*if ($mode == 1 && count($PRINTERSLIST) > 0)
{
processObjects(PRINTER_TYPE, DELETE_ACTION);
}*/
// Récupère les imprimantes dans GLPI
$printer_names = array();
if (count($PRINTERSLIST) > 0) {
$query_PRN = "select distinct ID, name from glpi_printers where deleted='0' ";
$result_PRN = $DB->query($query_PRN) or die($DB->error());
if ($DB->numrows($result_PRN) > 0) {
while ($data = $DB->fetch_array($result_PRN)) {
$printer_names[$data["name"]] = $data["ID"];
}
}
}
// Complétion des imprimantes et suppression de celles à ne pas importer
$numrows = 0;
foreach ($PRINTERSLIST as $prn_no => &$printer) {
if ($printer->portType <= PORT_TYPE_USB) {
$printer->getName();
if ($printer->server != '' && !isset($printer_names[$printer->name])) {
$numrows++;
} else {
unset($PRINTERSLIST[$prn_no]);
}
} else {
unset($PRINTERSLIST[$prn_no]);
}
}
unset($printer_names);
// Importation
if ($mode == 1 && isset($_POST['toimport'])) {
foreach ($_POST['toimport'] as $prn_no => $val) {
if ($val == "on") {
$PRINTERSLIST[$prn_no]->addToDB();
unset($PRINTERSLIST[$prn_no]);
$numrows--;
}
}
}
unset($_POST['toimport']);
// Affichage
echo "<div align='center'>";
if ($numrows) {
$readOnly = !haveRight("ocsng", "w");
$parameters = "objectType=" . PRINTER_TYPE . "&actionId=" . IMPORT_PRINTERS_ACTION;
printPager($start, $numrows, $_SERVER["PHP_SELF"], $parameters);
// delete end
array_splice($PRINTERSLIST, $start + $_SESSION["glpilist_limit"]);
// delete begin
//.........这里部分代码省略.........