PHP MySQL SSL PDO Connection

分类
代码库
更新时间
2019-05-17 20:08:33
<?php
class databaseClass_ssl extends PDO{
          protected $engine = 'mysql';
          protected $host = 'localhost';
          protected $port = 3306;
          protected $database = 'database_ssl';
          protected $user = 'pdo';
          protected $pass = 'pass';
          protected $dns;
          protected $DbPrefix = 'do_';
          
   public function __construct(){ 
     try{ 
          if($this->database){
            /* This exists as of PHP 5.3.7 and MySQL 5.6 */
            $this->dns = $this->engine.':host='.$this->host.';port='.$this->port.';dbname='.$this->database.';';
            parent::__construct($this->dns, $this->user, $this->pass, array(


            PDO::ATTR_PERSISTENT => true, // pcoonect otwarte po?aczenie 
            PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'', /* UTF-8 */
            PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, /* bufor */
            PDO::MYSQL_ATTR_KEY =>'/client-key.pem',
            PDO::MYSQL_ATTR_SSL_CERT =>'/client-cert.pem',
            PDO::MYSQL_ATTR_SSL_CA =>'/ca.pem')); /* lista dozwolonych szyfrów wykorzystanych do szyfrowania SSL. */
            }else{
                return false;
            } 
          }catch(PDOException $e){
                print_r($e);
          }
    }
  public function dbprefix(){ 
       return $this->DbPrefix;
    } 
}

腾讯云 / 腾讯AI / 腾讯开源 / 南沙新区 / 信用
分享工作室[粤ICP备16004795号-2] Date:2020-08-07 23:39:03(UTC) RunTime:0.012