-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel_db.php
More file actions
50 lines (37 loc) · 784 Bytes
/
Model_db.php
File metadata and controls
50 lines (37 loc) · 784 Bytes
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
<?php
/**
* Description of Model_db
*
* @author Petr Kukrál
*/
class Model_db {
private $host;
private $dbname;
private $user;
private $password;
private $id_connect;
public function __construct($host, $dbname, $user, $password)
{
$this->host = $host;
$this->dbname = $dbname;
$this->user = $user;
$this->password = $password;
}
public function query($query)
{
$this->connect();
$rows = mysql_query($query, $this->id_connect);
$this->disconnect();
return $rows;
}
private function connect()
{
$this->id_connect = mysql_connect($this->host,$this->user,$this->password);
mysql_select_db($this->dbname,$this->id_connect);
}
private function disconnect()
{
mysql_close($this->id_connect);
}
}
?>