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 MySqliDriver extends AbstractDatabaseDriver
32: {
33: public function connect($host, $username, $password, $database, $port = null)
34: {
35: $connection = new mysqli($host, $username, $password, $database, $port);
36:
37: if ($connection->connect_error)
38: {
39: throw new SQLException($mysqli->connect_error,$mysqli->connect_errno);
40: }
41: return $connection;
42: }
43:
44: public function dissconnect($connection)
45: {
46: $connection->close();
47: }
48:
49: public function getAffectedRows($connection)
50: {
51: return $connection->affected_rows;
52: }
53:
54: public function query($sql, $connection)
55: {
56: return $connection->query($sql);
57: }
58:
59: public function resultSetObject($resultResource, $className = null)
60: {
61: if($className==null)
62: {
63: return $resultResource->fetch_object();
64: }
65: return $resultResource->fetch_object($className);
66: }
67:
68: public function resultSetArray($resultResource)
69: {
70: return $resultResource->fetch_array();
71: }
72:
73: public function countRows($resultResource)
74: {
75: return $resultResource->num_rows();
76: }
77:
78: public function countColumns($resultResource)
79: {
80: return count($resultResource->fetch_fields());
81: }
82:
83: public function getInsertedId($connection)
84: {
85: return $connection->insert_id;
86: }
87: }
88:
89: ?>
90: