/*
*pgsql类
*/
class pgdb {
public $pdo;
public static $PDOInstance;
public $config;
public $data;
public $filed = '*';
public $table;
public $limit;
public $order;
public $where;
public $left;
const LOGIN = 7;
const USER = 1;
const GROUP = 2;
const USERGROUP = 3;
const LOG = 6;
const WARING = 1;
const ERROR = 2;
const INFO = 0;
공개 함수 __construct() {
if (!self::$PDOInstance) {
$this->config = json_decode(file_get_contents("./config/db .json"), true);
$config = $this->config;
$host = $config["data_base"]["db_host"];
$dbname = $config[" data_base"]["db_name"];
$port = $config["data_base"]["db_port"];
$username = $config["data_base"]["db_user"];
$password = $config["data_base"]["db_pwd"];
if ($config["data_base"]["db_host"] != 'localhost') {
$hosturl = "host=$ 호스트;";
}
시도해 보세요
{
self::$PDOInstance = new PDO("pgsql:"
. $hosturl
. "port=$port;"
. "dbname=$dbname;"
, $username
, $password
, 배열(
PDO::ATTR_PERSISTENT => true,
)
);
} catch(예외 $ex) {
header("Content-type: text/html; charset=utf-8");
$error = "数据库初始화失败,已强system断开链接。
抓取到的异常栈如下:
" . print_r($ex, true) . "";