1 |
bareface |
1.1 |
<?php |
2 |
|
|
|
3 |
|
|
class YakkaMySqlDatabase { |
4 |
|
|
var $connection; |
5 |
|
|
|
6 |
|
|
function YakkaMySqlDatabase() { |
7 |
|
|
} |
8 |
|
|
|
9 |
|
|
function connect($host, $database, $user, $password) { |
10 |
|
|
if ($this->connection = @mysql_connect($host, $user, $password, true)) |
11 |
|
|
mysql_select_db($database, $this->connection); |
12 |
|
|
} |
13 |
|
|
|
14 |
|
|
function execute($sql) { |
15 |
|
|
return mysql_query($sql, $this->connection); |
16 |
|
|
} |
17 |
|
|
|
18 |
|
|
function escapeString($string) { |
19 |
|
|
return mysql_escape_string($string); |
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
function queryRecord($sql) { |
23 |
|
|
$row = null; |
24 |
|
|
if ($result = $this->execute($sql)) { |
25 |
|
|
$row = mysql_fetch_assoc($result); |
26 |
|
|
mysql_free_result($result); |
27 |
|
|
} |
28 |
|
|
return $row; |
29 |
|
|
} |
30 |
|
|
|
31 |
|
|
function queryRecordset($sql) { |
32 |
|
|
$recordset = array(); |
33 |
|
|
if ($result = $this->execute($sql)) { |
34 |
|
|
while($row = mysql_fetch_assoc($result)) |
35 |
|
|
$recordset[] = $row; |
36 |
|
|
|
37 |
|
|
mysql_free_result($result); |
38 |
|
|
} |
39 |
|
|
return $recordset; |
40 |
|
|
} |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
?> |