1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: namespace picon;
24:
25: 26: 27: 28: 29: 30:
31: class MySqlDriver extends AbstractDatabaseDriver
32: {
33: public function connect($host, $username, $password, $database, $port = null)
34: {
35: $connection = mysql_connect($host, $username, $password);
36:
37: if($connection==false)
38: {
39: throw new SQLException(mysql_error());
40: }
41: $selection = mysql_select_db($database, $connection);
42: if($selection==false)
43: {
44: throw new SQLException(mysql_error($connection));
45: }
46: return $connection;
47: }
48:
49: public function dissconnect($connection)
50: {
51: mysql_close($connection);
52: }
53:
54: public function getAffectedRows($connection)
55: {
56: return mysql_affected_rows($connection);
57: }
58:
59: public function query($sql, $connection)
60: {
61: $result = mysql_query($sql, $connection);
62: if (!$result)
63: {
64: throw new SQLException(mysql_error($connection));
65: }
66: return $result;
67: }
68:
69: public function resultSetObject($resultResource, $className = null)
70: {
71: if($className==null)
72: {
73: return mysql_fetch_object($resultResource);
74: }
75: return mysql_fetch_object($resultResource, $className);
76: }
77:
78: public function resultSetArray($resultResource)
79: {
80: return mysql_fetch_array($resultResource);
81: }
82:
83: public function countRows($resultResource)
84: {
85: return mysql_num_rows($resultResource);
86: }
87:
88: public function countColumns($resultResource)
89: {
90: return mysql_num_fields($resultResource);
91: }
92:
93: public function getInsertedId($connection)
94: {
95: return mysql_insert_id($connection);
96: }
97: }
98:
99: ?>
100: