WEB开发网
开发学院数据库DB2 使用 DB2 pureXML 和 PHP 构建 Support Knowledge... 阅读

使用 DB2 pureXML 和 PHP 构建 Support Knowledge Base(上)

 2010-02-25 00:00:00 来源:WEB开发网   
核心提示: 清单 2. db.php<?phpclassDB{private$conn;function__construct(){$database="kbase";$hostname="localhost";$port=50000;$user="u

清单 2. db.php

<?php 
class DB { 
  private $conn; 
 
  function __construct() { 
    $database = "kbase"; 
    $hostname = "localhost"; 
    $port = 50000; 
    $user = "username"; 
    $password = "password"; 
 
    $db_connect_string = "DRIVER={IBM DB2 ODBC DRIVER};" 
      . "DATABASE=$database;" 
      . "HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;" 
      . "UID=$user;PWD=$password;"; 
 
    $this->conn = db2_connect($db_connect_string, '', ''); 
 
    if(!$this->conn) { 
      die(db2_conn_errormsg($this->conn)); 
    } 
  } 
 
  function safe_no_html($string, $include_quotes=true) { 
    htmlentities($string, ENT_QUOTES, 'utf-8'); 
 
    if($include_quotes) 
return "'".db2_escape_string($string)."'"; 
    else return db2_escape_string($string); 
  } 
 
  function query($sql) { 
    $result = db2_exec($this->conn, $sql); 
 
    if(!$result) { 
      die(db2_stmt_errormsg()); 
    } else { 
      return $result; 
    } 
  } 
 
  function get_row($result) { 
    return db2_fetch_array($result); 
  } 
} 
?> 

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:使用 DB pureXML

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接