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


PHP init_db函数代码示例

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


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

示例1: build_points

function build_points()
{
    $sqlite = init_db();
    $points = parse_db($sqlite);
    $sqlite->close();
    return $points;
}
开发者ID:joksnet,项目名称:js-games,代码行数:7,代码来源:score.php

示例2: search_db

function search_db($netid)
{
    global $dbfields;
    if (!preg_match("/\\A[a-z]{3}([0-9]*)\\Z/i", $netid)) {
        return array();
    }
    init_db();
    $query = "select * from users where netid='" . pg_escape_string($netid) . "'";
    $result = pg_query($query);
    $present = pg_fetch_array($result, null, PGSQL_ASSOC);
    if ($present == null) {
        return array();
    }
    $person = new Person($netid);
    pg_free_result($result);
    foreach ($dbfields as $f) {
        $query = "select * from " . $f . " where netid='" . pg_escape_string($netid) . "'";
        $result = pg_query($query);
        while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
            $value = $line[$f];
            if ($line["ldap"] === "f") {
                $person->db_fields[$f][] = $value;
            } else {
                $person->ldap_fields[$f][] = $value;
            }
        }
        pg_free_result($result);
    }
    $person->refresh_db();
    return array($person);
}
开发者ID:rde1024,项目名称:cwrufind,代码行数:31,代码来源:dbutils.php

示例3: get_keyword

function get_keyword($id)
{
    $db = init_db();
    $kw_sql = "SELECT DISTINCT kw_content FROM plu_keywords WHERE kw_id = '{$id}'";
    $kw = $db->get_var($kw_sql);
    return $kw;
}
开发者ID:kingwang317,项目名称:it4fun-guam,代码行数:7,代码来源:blog_list.php

示例4: init_env

function init_env($time)
{
    chdir("/home/crowler/");
    init_db();
    $symbols = find_symbols_list();
    add_debug($time);
    return $symbols;
}
开发者ID:etiennechabert,项目名称:TradingResearch,代码行数:8,代码来源:fullQuery.php

示例5: check_auth

 function check_auth($data)
 {
     $db = init_db();
     if (!$db) {
         return false;
     }
     $login = str_replace("'", '', str_replace(';', '', $data['usr']));
     //		$sql="SELECT acc_subj,u_id,u_email,u_nick,LOWER(u_url) u_url,u_grp,u_img,u_name,u_sname,u_twitter,u_showtwit,u_maketwit,u_country,u_city,u_gender,u_birth,u_phone,u_sms,u_smoke,u_alcohol,u_lifestyle,u_about,u_musicstyles,u_last_login,u_pwd,u_id,u_nub,u_weight,u_bg,u_bg_mod FROM usr where u_lock='' AND u_grp!='fdj' AND  (u_nick='$login' OR u_email='$login')";
     $sql = "SELECT\tu_id,u_grp,u_url,u_email,u_pwd,u_name,u_sname,u_img,u_gender,u_bdate,u_createdate,u_lastlogin,u_lock,u_passre,\r\n\t\t\t\t\t\tGROUP_CONCAT(u2t_key_t) u_themes\r\n\t\t\t\t\tFROM user LEFT JOIN user2theme ON(u2t_key_u=u_id) where u_email='{$login}'\r\n\t\t\t\t\tGROUP BY u_id";
     $usr = $db->query_row($sql);
     if (!$usr) {
         return false;
     }
     if ($usr['u_pwd'] != $data['pwd']) {
         return false;
     }
     if (!empty($usr['u_lock'])) {
         set_error_ex('user_locked', USR_MSG);
         return false;
     }
     $auth_groups = array('adm' => array('site_auth', 'admin_auth'), 'usr' => array('site_auth'));
     $acc = array('site_auth' => false, 'manager_auth' => false, 'admin_auth' => false);
     foreach ($auth_groups[$usr['u_grp']] as $descriptor) {
         $acc[$descriptor] = 1;
     }
     if (!$acc[$this->params['name']]) {
         return false;
     }
     //$GLOBALS['auth_login_id']=$usr['u_id']; $GLOBALS['auth_login_subj']=$usr['acc_subj'];
     // success. Store last in date
     $sql = "UPDATE usr SET u_last_login='" . date('YmdHis') . "' WHERE u_id='{$usr['u_id']}'";
     $db->query($sql);
     // correct date
     if (substr($usr['u_last_login'], 0, 4) == '0000') {
         $usr['u_last_login'] = date('d.m.Y');
     } else {
         $usr['u_last_login'] = date('d.m.Y', strtotime($usr['u_last_login']));
     }
     // store user data
     unset($usr['u_pwd']);
     switch ($usr['u_grp']) {
         case 'saller':
             $sql = "SELECT * FROM sallers WHERE s_id=" . $usr['u_key_subj'];
             $add = $db->query_row($sql);
             break;
         case 'vendor':
             $sql = "SELECT * FROM vendors WHERE v_id=" . $usr['u_key_subj'];
             $add = $db->query_row($sql);
             break;
         default:
             $add = array();
     }
     $usr = array_merge($usr, $add);
     $_SESSION['Jlib_auth'] = $usr;
     $_SESSION['Jlib_auth'] = array_merge($_SESSION['Jlib_auth'], $acc);
     return true;
 }
开发者ID:kronius,项目名称:vidpro,代码行数:57,代码来源:auth.php

示例6: list_credentials

function list_credentials()
{
    $db = init_db();
    // Must use explicit select instead of * to get the rowid
    $query = $db->query('select userid, credentials from credentials');
    $result = array();
    while ($singleResult = $query->fetchArray(SQLITE3_ASSOC)) {
        array_push($result, $singleResult);
    }
    return $result;
}
开发者ID:tis-innovation-park,项目名称:IoT-Integreen,代码行数:11,代码来源:util.php

示例7: get_image_data

function get_image_data($netid)
{
    init_db();
    $query = "SELECT image_id, image_name, profile FROM images WHERE netid='" . pg_escape_string($netid) . "'";
    $results = pg_query($query);
    if ($results) {
        $images = pg_fetch_all($result);
    } else {
        $images = null;
    }
    return $images;
}
开发者ID:rde1024,项目名称:cwrufind,代码行数:12,代码来源:image.php

示例8: get_breadcrumb

function get_breadcrumb($cate_id, $breadcrumb_str = "")
{
    $db = init_db();
    $breadcrumb_result = $db->get_results("SELECT cate_id,cate_name,parent_id FROM `plu_product_category` WHERE cate_id = '{$cate_id}' ");
    //print_r($breadcrumb_result);
    if (isset($breadcrumb_result)) {
        foreach ($breadcrumb_result as $row) {
            //echo $row->cate_name;
            if ($breadcrumb_str == "") {
                $breadcrumb_str = " > " . $row->cate_name;
            } else {
                $breadcrumb_str = " > " . "<a href='" . WEBROOT . "/index.php?cmsid=2&cate_id={$row->cate_id}'>{$row->cate_name}</a>" . $breadcrumb_str;
            }
            if ($row->parent_id != -1) {
                $breadcrumb_str = get_breadcrumb($row->parent_id, $breadcrumb_str);
            }
        }
    }
    return $breadcrumb_str;
}
开发者ID:kingwang317,项目名称:it4fun-guam,代码行数:20,代码来源:index_bread.php

示例9: refresh_db

 function refresh_db()
 {
     init_db();
     $query = "select timestamp from users where netid='" . pg_escape_string($this->netid) . "'";
     $result = pg_query($query);
     $line = pg_fetch_array($result, null, PGSQL_ASSOC);
     pg_free_result($result);
     if (!$line) {
         $query = "insert into users (netid, from_ldap) values ('" . pg_escape_string($this->netid) . "', false)";
         $result = pg_query($query);
         pg_free_result($result);
     } else {
         if (!isold($line["timestamp"])) {
             return;
         }
     }
     $person = search_ldap(array("netid" => $this->netid));
     $this->purge();
     $this->merge($person[0]);
 }
开发者ID:rde1024,项目名称:cwrufind,代码行数:20,代码来源:person.php

示例10: add_index

function add_index()
{
    $connection = init_db();
    for ($i = 0; $i <= 2; $i++) {
        $query = "select programId,programName,compere,tabSet from a_program";
        $start = $i * 10;
        $limit = "limit {$start},10";
        $select_sql = $query . " " . $limit;
        $select_res = mysql_query($select_sql) or die("query failed");
        while ($r = mysql_fetch_array($select_res)) {
            $programId = $r["programId"];
            $str = $r["programName"] . "" . $r["compere"] . "" . $r["tabSet"];
            $unicode = str2Unicode($str);
            $update = "update a_program set searchindex='{$unicode}' where programId='{$programId}'";
            echo "{$update}\n";
            mysql_query($update) or die("update failed");
        }
        mysql_free_result($select_res);
    }
    mysql_close($connection);
}
开发者ID:sdgdsffdsfff,项目名称:nginx_lua,代码行数:21,代码来源:index.php

示例11: init

function init(&$db, $checkSession = NULL)
{
    $ok = TRUE;
    // Set timezone
    if (!ini_get('date.timezone')) {
        date_default_timezone_set('UTC');
    }
    // Set session cookie path
    ini_set('session.cookie_path', getAppPath());
    // Open session
    session_name(SESSION_NAME);
    session_start();
    if (!is_null($checkSession) && $checkSession) {
        $ok = isset($_SESSION['consumer_key']) && isset($_SESSION['resource_id']) && isset($_SESSION['user_consumer_key']) && isset($_SESSION['user_id']) && isset($_SESSION['isStudent']);
    }
    if (!$ok) {
        $_SESSION['error_message'] = 'Unable to open session.';
    } else {
        // Open database connection
        $db = open_db(!$checkSession);
        $ok = $db !== FALSE;
        if (!$ok) {
            if (!is_null($checkSession) && $checkSession) {
                // Display a more user-friendly error message to LTI users
                $_SESSION['error_message'] = 'Unable to open database.';
            }
        } else {
            if (!is_null($checkSession) && !$checkSession) {
                // Create database tables (if needed)
                $ok = init_db($db);
                // assumes a MySQL/SQLite database is being used
                if (!$ok) {
                    $_SESSION['error_message'] = 'Unable to initialise database.';
                }
            }
        }
    }
    return $ok;
}
开发者ID:jtibbetts,项目名称:php_ltitp_ndar,代码行数:39,代码来源:lib.php

示例12: do_reply_contact

 function do_reply_contact()
 {
     $db = init_db();
     if (!(isset($_GET["con_id"]) && preg_match("/^[0-9]*\$/", $_GET["con_id"]))) {
         redirect($this->plu_path . "&func=show_contact_list", 0, "你所要變更的消息不合法");
         exit;
     }
     $con_id = $_GET["con_id"];
     $con_content = isset($_POST['content']) ? $_POST['content'] : "";
     $sql = "UPDATE plu_contact SET con_reply='{$con_content}',con_reply_time=NOW() WHERE con_id = '{$con_id}' ";
     $db->query($sql);
     //echo $sql;
     redirect($this->plu_path . "&func=show_contact_list", 0, "變更已完成");
 }
开发者ID:kingwang317,项目名称:it4fun-guam,代码行数:14,代码来源:index.php

示例13: ini_set

ini_set('date.timezone', 'Asia/Shanghai');
if ($argc < 3) {
    $url = $_SERVER['PHP_SELF'];
    $filename = substr($url, strrpos($url, '/'));
    echo "argument error, usage: {$filename} [update|backup|restore|dump] localhost";
}
require_once 'conf.php';
$mode = $argv[1];
$conf = $argv[2];
$db_host = $db_argv[$conf]['host'];
$db_user = $db_argv[$conf]['user'];
$db_pass = $db_argv[$conf]['pass'];
$db_name = $db_argv[$conf]['name'];
$db_port = $db_argv[$conf]['port'];
$db_version = init_db();
$db = new mysqli($db_host, $db_user, $db_pass, $db_name, $db_port);
$db->query("SET NAMES utf8;");
if ($mode == "update") {
    update_db();
} else {
    if ($mode == "backup") {
        export_db(true);
    } else {
        if ($mode == "restore") {
            require_once "backup/" . $argv[3] . ".php";
        } else {
            if ($mode == "export") {
                update_db();
                export_db(false);
            } else {
开发者ID:sacramento04,项目名称:practice,代码行数:30,代码来源:main.php

示例14: isset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<?php 
include 'php/util/db.php';
include 'php/util/common.php';
$q = isset($_REQUEST["page"]) ? $_REQUEST["page"] : "home";
$PAGES_DIR = "./php/pages/";
$conn = init_db();
$page = get_page($conn, $q);
$tabs = get_tabs($conn);
//page - file, name, display_name
$show_ticker = $show_slideshow = $q == "home";
?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="content-language" content="en" />
    <meta name="robots" content="all,follow" />

    <meta name="author" lang="en" content="All: Satheesh Kumar M [sathyz.wordpress.com]; e-mail: sathyz@gmail.com" />

    <meta name="description" content="Rainbow Novelties - specialises in creating custom designed bags for the discerning corporations" />
    <meta name="keywords" content="rainbow novelties bags apparels gifts" />

    <link rel="icon" type="image/x-icon" href="logo.ico" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/reset.css" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/main.css" />
    <!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="css/main-msie.css" /><![endif]-->
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/style.css" />
    <link rel="stylesheet" media="print" type="text/css" href="css/print.css" />
开发者ID:sathyz,项目名称:site_rn,代码行数:31,代码来源:index.php

示例15: get_profile_privileges

function get_profile_privileges()
{
    $db = init_db();
    $pris = array();
    $mod_ids = get_profile_modules();
    foreach ($mod_ids as $mod_id) {
        $sql = "SELECT pri_id,pri_name,mod_id,stype_id FROM sys_privileges WHERE mod_id = '{$mod_id}'";
        $results = $db->get_results($sql);
        if (isset($results)) {
            foreach ($results as $row) {
                $pris[] = array('pri_id' => $row->pri_id, 'pri_name' => $row->pri_name, 'mod_id' => $row->mod_id, 'stype_id' => $row->stype_id);
            }
        }
    }
    return $pris;
}
开发者ID:kingwang317,项目名称:it4fun-guam,代码行数:16,代码来源:auth.inc.php


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