刚坐在车里就开始电闪雷鸣。听着隆隆的雷声,没有恐慌,到有几分振奋人心的舒心感、酣畅淋漓感。朝外望去,突然间,狂风夹杂着骤雨席卷而来,一泻千里。瞬间暴雨如注,打在地上,溅起朵朵浪花,在热浪的蒸腾下激起层层水雾。满大街是慌乱的人群,行人跑着、叫喊着,唧唧喳喳的赶着在房檐下躲雨。这时候伞是没有用的,挡不住狂风暴雨的袭击,无论是带了伞的,还是没带伞的,全都躲在了房檐下。
核心代码:
/* *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; public function __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=$host;"; } try { self::$PDOInstance = new PDO("pgsql:" . $hosturl . "port=$port;" . "dbname=$dbname;" , $username , $password , array( PDO::ATTR_PERSISTENT => true, ) ); } catch (Exception $ex) { header("Content-type: text/html; charset=utf-8"); $error = "数据库初始化失败,已强制断开链接。<br />抓取到的异常栈如下:<br /><pre>" . print_r($ex, true) . "</pre>"; die($error); } try { self::$PDOInstance->query("SET client_encoding='UTF-8';"); self::$PDOInstance->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); self::$PDOInstance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (Exception $exc) { $this->pdo=NULL; $doc = <<<DOC <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="layer/jquery-1.11.1.min.js"></script> <script src="layer/layer.js"></script> <head> <body> DOC; print $doc; $info=L('服务器变更请刷新'); print("<script>layer.msg('".$info."', {icon: 2,time: 30000},function(){location.reload();});</script>"); print('</body></html>'); exit(); } } $this->pdo = self::$PDOInstance; } }
以上就是简单的pgsql pdo php操作类实现代码。如果有缘,错过了还会重来;如果无缘,相遇了也会离开。聚有聚的理由,离有离的借口,人生没有如果,只有后果和结果。更多关于简单的pgsql pdo php操作类实现代码请关注haodaima.com其它相关文章!