Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1: <?php
- 2:
- 3:
- 4:
- 5: class DB
- 6:
- 7: {
- 8:
- 9: // Connection parameters
- 10:
- 11:
- 12:
- 13: var $host = 'localhost';
- 14:
- 15: var $user ="moneyau_money2";
- 16:
- 17: var $password ="panameasi2lei";
- 18:
- 19: var $persistent = false;
- 20:
- 21: var $adminid='admin';
- 22:
- 23: var $adminipwd='admin';
- 24:
- 25:
- 26:
- 27:
- 28:
- 29:
- 30:
- 31:
- 32:
- 33: // Database connection handle
- 34:
- 35: var $conn = NULL;
- 36:
- 37:
- 38:
- 39: // Query result
- 40:
- 41: var $result = false;
- 42:
- 43:
- 44:
- 45: // function DB($host, $user, $password, $database, $persistent = false)
- 46:
- 47: function DB()
- 48:
- 49: {
- 50:
- 51:
- 52:
- 53: }
- 54:
- 55:
- 56:
- 57: function open()
- 58:
- 59: {
- 60:
- 61: // Choose the appropriate connect function
- 62:
- 63: if ($this->persistent) {
- 64:
- 65: $func = 'mysql_pconnect';
- 66:
- 67: } else {
- 68:
- 69: $func = 'mysql_connect';
- 70:
- 71: }
- 72:
- 73:
- 74:
- 75: // Connect to the MySQL server
- 76:
- 77: $this->conn = $func($this->host, $this->user, $this->password);
- 78:
- 79: if (!$this->conn) {
- 80:
- 81: return false;
- 82:
- 83: }
- 84:
- 85:
- 86:
- 87: // Select the requested database
- 88:
- 89: if (!@mysql_select_db($this->database, $this->conn)) {
- 90:
- 91: return false;
- 92:
- 93: }
- 94:
- 95:
- 96:
- 97: return true;
- 98:
- 99: }
- 100:
- 101:
- 102:
- 103:
- 104:
- 105: function close()
- 106:
- 107: {
- 108:
- 109: return (@mysql_close($this->conn));
- 110:
- 111: }
- 112:
- 113:
- 114:
- 115: function error()
- 116:
- 117: {
- 118:
- 119: return (mysql_error());
- 120:
- 121: }
- 122:
- 123:
- 124:
- 125: function query($sql = '')
- 126:
- 127: {
- 128:
- 129: $this->result = @mysql_query($sql, $this->conn);
- 130:
- 131: return ($this->result != false);
- 132:
- 133: }
- 134:
- 135:
- 136:
- 137: function affectedRows()
- 138:
- 139: {
- 140:
- 141: return (@mysql_affected_rows($this->conn));
- 142:
- 143: }
- 144:
- 145:
- 146:
- 147: function numRows()
- 148:
- 149: {
- 150:
- 151: return (@mysql_num_rows($this->result));
- 152:
- 153: }
- 154:
- 155: function fieldName($field)
- 156:
- 157: {
- 158:
- 159: return (@mysql_field_name($this->result,$field));
- 160:
- 161: }
- 162:
- 163: function insertID()
- 164:
- 165: {
- 166:
- 167: return (@mysql_insert_id($this->conn));
- 168:
- 169: }
- 170:
- 171:
- 172:
- 173: function fetchObject()
- 174:
- 175: {
- 176:
- 177: return (@mysql_fetch_object($this->result, MYSQL_ASSOC));
- 178:
- 179: }
- 180:
- 181:
- 182:
- 183: function fetchArray()
- 184:
- 185: {
- 186:
- 187: return (@mysql_fetch_array($this->result, MYSQL_NUM));
- 188:
- 189: }
- 190:
- 191:
- 192:
- 193: function fetchAssoc()
- 194:
- 195: {
- 196:
- 197:
- 198: var $database ='moneyau_money2';
- 199: return (@mysql_fetch_assoc($this->result));
- 200:
- 201: }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement