Rev 29 | Rev 41 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
27 | PointedEar | 1 | <?php |
2 | |||
29 | PointedEar | 3 | require_once __DIR__ . '/Database.php'; |
27 | PointedEar | 4 | |
5 | class MySQLDB extends Database |
||
6 | { |
||
7 | /** |
||
8 | * Database host |
||
9 | * @var string |
||
10 | */ |
||
11 | protected $_host; |
||
12 | |||
13 | /** |
||
14 | * Database name |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $_dbname; |
||
18 | |||
19 | /** |
||
20 | * Username to access the database |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $_username; |
||
24 | |||
25 | /** |
||
26 | * Password to access the database |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $_password; |
||
30 | |||
31 | /* |
||
32 | * Optional charset parameter value |
||
33 | */ |
||
34 | protected $_charset = null; |
||
35 | |||
32 | PointedEar | 36 | /** |
37 | * (non-PHPdoc) |
||
38 | * @see Database::_leftQuote |
||
39 | */ |
||
40 | protected $_leftQuote = '`'; |
||
41 | |||
42 | /** |
||
43 | * (non-PHPdoc) |
||
44 | * @see Database::_rightQuote |
||
45 | */ |
||
46 | protected $_rightQuote = '`'; |
||
47 | |||
27 | PointedEar | 48 | public function __construct() |
49 | { |
||
50 | $this->_dsn = "mysql:host={$this->_host}" |
||
51 | . (!is_null($this->_dbname) ? ";dbname={$this->_dbname}" : '') |
||
52 | . (!is_null($this->_charset) ? ";charset={$this->_charset}" : ''); |
||
53 | |||
54 | if (!is_null($this->_charset)) |
||
55 | { |
||
56 | $this->_options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES " . $this->_charset; |
||
57 | } |
||
58 | |||
59 | parent::__construct(); |
||
60 | } |
||
61 | } |