-
Notifications
You must be signed in to change notification settings - Fork 1
/
db3.php
56 lines (46 loc) · 1.32 KB
/
db3.php
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
class DB2{
public $host;
public $port;
public $user;
public $pass;
public $charset;
public $dbname;
public $link;
public $last_sql;
public function __construct($params = array()){
echo 'bbb<hr/>';
$this->host = isset($params['host'])?$params['host']:'127.0.0.1';
$this->port = isset($params['port'])?$params['port']:'3306';
$this->user = isset($params['user'])?$params['user']:'root';
$this->pass = isset($params['pass'])?$params['pass']:'root';
$this->charset = isset($params['charset'])?$params['charset']:'utf8';
$this->dbname = isset($params['dbname'])?$params['dbname']:'test';
$this->connect();
//$this->charset();
}
public function connect(){
echo 'aaa<hr/>',$this->host,$this->port,$this->user,$this->pass;
$link = mysql_connect("$this->host:$this->port",$this->user,$this->pass);
//echo 'bbb<hr/>';
//var_dump($link);
if(!$link =mysql_connect("$this->host:$this->port",$this->user,$this->pass)){
echo 'DBDAIL 01<br />';
echo mysql_errno().':'.mysql_error();
die();
}else{
$this->link = $link;
var_dump($this->link);
echo "<br />";
}
}
// private ffunction setCharSet(){
// if (!mysql_connect("set names $this->charset")) {
// echo 'DBDAIL 01<br />';
// echo mysql_errno().':'.mysql_error();
// die();
// }
// }
}
$db = new DB2();
var_dump($db );