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


PHP db::conn方法代码示例

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


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

示例1: connect

 public static function connect()
 {
     self::$conn = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";", DB_USER, DB_PASS);
     self::$conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
     self::$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     self::$result = false;
 }
开发者ID:devolutionary,项目名称:wod,代码行数:7,代码来源:Database.php

示例2: getInstance

 /**
  * static function to get instance of db
  * return type
  */
 public static function getInstance()
 {
     if (self::$conn == null) {
         self::$conn = new db();
     }
     return self::$conn;
 }
开发者ID:amagdy529,项目名称:Cafeteria_Project,代码行数:11,代码来源:DataBase_Class.php

示例3:

 function __destruct()
 {
     if (is_resource(self::$conn)) {
         mysql_close(self::$conn);
     }
     self::$conn = null;
     self::$object = null;
 }
开发者ID:art-youth,项目名称:framework,代码行数:8,代码来源:db.php

示例4: getList

function getList()
{
    //连接数据库
    $obj = new db('localhost', 'root', 'root', 'recursion');
    $con = $obj->conn();
    $sql = "SELECT id,cname,concat(path,',',id)as fpath FROM category ORDER BY fpath asc";
    $query = mysqli_query($con, $sql);
    while ($row = mysqli_fetch_assoc($query)) {
        $row['cname'] = str_repeat('  ', count(explode(',', trim($row['fpath'], ',')))) . '!--' . $row['cname'];
        $res[] = $row;
    }
    return $res;
}
开发者ID:ryanlee1992,项目名称:recursion,代码行数:13,代码来源:path.php

示例5: conn

 public static function conn()
 {
     self::$conn = new mysqli(global_val("servername"), global_val("username"), global_val("password"));
     // Check connection
     if (self::$conn->connect_error) {
         die("Connection failed: " . self::$conn->connect_error);
     }
     //check if we need to create the database
     self::create_database();
     self::$conn->select_db(global_val("databasename"));
     //check if we need to create tables
     self::create_tables();
     return self::$conn;
 }
开发者ID:Aharobot,项目名称:turtlebot-server,代码行数:14,代码来源:db.php

示例6: getList

function getList($id, &$result = [])
{
    //连接数据库
    $obj = new db('localhost', 'root', 'root', 'recursion');
    $con = $obj->conn();
    $sql = "SELECT * FROM columns WHERE id={$id}";
    $res = mysqli_query($con, $sql);
    $row = mysqli_fetch_assoc($res);
    if ($row) {
        $result[] = $row;
        getList($row['pid'], $result);
    }
    return $result;
}
开发者ID:ryanlee1992,项目名称:recursion,代码行数:14,代码来源:displayLink.php

示例7: recur

function recur(&$pid = 0, &$result = [], $spac = 0)
{
    //连接数据库
    $obj = new db('localhost', 'root', 'root', 'recursion');
    $con = $obj->conn();
    $sql = "SELECT * FROM columns WHERE pid={$pid}";
    $res = mysqli_query($con, $sql);
    $spac = $spac + 2;
    while ($row = mysqli_fetch_assoc($res)) {
        $row['cname'] = str_repeat('  ', $spac) . '!-' . $row['cname'];
        $result[] = $row;
        recur($row['id'], $result, $spac);
    }
    return $result;
}
开发者ID:ryanlee1992,项目名称:recursion,代码行数:15,代码来源:index.php

示例8: read

 public static function read()
 {
     $conn = db::conn();
     //return the most recent action_val
     $a = array();
     $result = $conn->query("select action_val from telep order by ID desc limit 1") or die("telep read failed");
     if ($row = $result->fetch_assoc()) {
         $a["action"] = $row['action_val'];
     } else {
         $a["action"] = "stop";
         //default
     }
     self::json_headers();
     echo json_encode($a);
     exit;
 }
开发者ID:Aharobot,项目名称:telepresence-turtlebot,代码行数:16,代码来源:api.php

示例9: getList

function getList($cid)
{
    $obj = new db('localhost', 'root', 'root', 'recursion');
    $con = $obj->conn();
    $sql = "SELECT id,cname,concat(path,',',id) as fpath from category WHERE id={$cid}";
    $query = mysqli_query($con, $sql);
    $row = mysqli_fetch_assoc($query);
    // $ids = explode(',',$row['fpath']);
    $ids = $row['fpath'];
    /*var_dump($ids);
    		exit;*/
    $sql_2 = "SELECT * FROM category where id in ({$ids}) order by id asc";
    $query_2 = mysqli_query($con, $sql_2);
    while ($row = mysqli_fetch_assoc($query_2)) {
        $result[] = $row;
    }
    return $result;
}
开发者ID:ryanlee1992,项目名称:recursion,代码行数:18,代码来源:plink.php

示例10: query

 public static function query($sql)
 {
     $sql = trim($sql);
     // 初始化数据库
     self::_init_mysql();
     self::$rsid = @mysqli_query(self::$conn, $sql);
     if (self::$rsid === false) {
         // 不要每次都ping,浪费流量浪费性能,执行出错了才重新连接
         $errno = mysqli_errno(self::$conn);
         if ($errno == 2013 || $errno == 2006) {
             @mysqli_close(self::$conn);
             self::$conn = null;
             return self::query($sql);
         }
         echo "Query SQL: " . $sql . "\n";
         echo "Error SQL: ErrorNo --- " . mysqli_errno(self::$conn) . ' --- Error --- ' . mysqli_error(self::$conn) . "\n";
         $backtrace = debug_backtrace();
         array_shift($backtrace);
         $narr = array('class', 'type', 'function', 'file', 'line');
         $err = "debug_backtrace:\n";
         foreach ($backtrace as $i => $l) {
             foreach ($narr as $k) {
                 if (!isset($l[$k])) {
                     $l[$k] = '';
                 }
             }
             $err .= "[{$i}] in function {$l['class']}{$l['type']}{$l['function']} ";
             if ($l['file']) {
                 $err .= " in {$l['file']} ";
             }
             if ($l['line']) {
                 $err .= " on line {$l['line']} ";
             }
             $err .= "\n\n";
         }
         echo $err;
         return false;
     } else {
         self::$query_count++;
         return self::$rsid;
     }
 }
开发者ID:cheihcheung,项目名称:phpspider,代码行数:42,代码来源:db.php

示例11: ping

 public static function ping()
 {
     if (!mysqli_ping(self::$conn)) {
         @mysqli_close(self::$conn);
         self::$conn = null;
         self::_init_mysql();
     }
 }
开发者ID:jackyxie,项目名称:phpspider,代码行数:8,代码来源:db.php

示例12: die

<?php

$tpl = $PAGE->start();
$USER->start($tpl);
if (!$USER->islogin || $USER->uid != 1 && $USER->uid != 2) {
    die('403 Forbidden');
}
$sql = trim(str_replace(array(chr(12), " "), array("\n", ' '), $_POST['sql']));
if ($sql != '') {
    $db2 = $db = db::conn(false);
    $db = $db->query($sql);
    if (!$db) {
        $tpl->assign('msg', $db2->errorinfo());
        $db = array();
        $ok = false;
    } else {
        $ok = true;
        $db = $db->fetchall(db::ass);
    }
    $tpl->assign('sql', $sql);
    $tpl->assign('db', $db);
    $tpl->assign('ok', $ok);
} else {
    $tpl->assign('sql', '');
    $tpl->assign('db', array());
    $tpl->assign('ok', null);
}
$tpl->display('tpl:sql');
开发者ID:istrwei,项目名称:hu60wap6,代码行数:28,代码来源:sql.php

示例13: conn

 /**
 * 连接数据库
 * 参数:
 * $read_only  如果为true,打开一个只读的数据库连接,只允许查询;否则打开一个可读可写的连接。实现分布式应用的读写分离。
 */
 protected static function conn($read_only = false)
 {
     return db::conn('user', $read_only);
 }
开发者ID:istrwei,项目名称:hu60wap6,代码行数:9,代码来源:userinfo.php

示例14: __construct

 function __construct()
 {
     $this->conn = db::conn();
     //connect to mysql
 }
开发者ID:Aharobot,项目名称:turtlebot-server,代码行数:5,代码来源:coffee_queue.php


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