-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySQL.php
More file actions
41 lines (33 loc) · 1.09 KB
/
Copy pathMySQL.php
File metadata and controls
41 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
// ---------------------------------
//
// MySQL DataBase Object v0.1
//
// ---------------------------------
class MySQL extends SQLDB {
public function __construct(
$_Name, $_Account = 'root:', $_CharSet = 'utf8', $_Option = null
) {
parent::__construct( $_Name );
$_Name = array_merge(
array('host' => 'localhost'),
is_string($_Name) ? array('dbname' => $_Name) : $_Name,
array('charset' => $_CharSet)
);
$_DSN = array();
foreach ($_Name as $_Key => $_Value)
$_DSN[] = "{$_Key}={$_Value}";
$_Account = explode(':', $_Account);
$this->dataBase = new PDO(
'mysql:' . join(';', $_DSN), $_Account[0], $_Account[1], $_Option
);
}
public function hasTable($_Name) {
return !! count( $this->query(array(
'select' => 'table_schema, table_name',
'from' => 'information_schema.tables',
'where' =>
"table_schema = '{$this->name}' and table_name = '{$_Name}'"
)) );
}
}