Project

General

Profile

« Previous | Next » 

Revision 1613

Added by darkviper over 12 years ago

little fixes in classs database and add new readonly property DbName

View differences:

class.database.php
36 36
class database {
37 37

  
38 38
	private $db_handle  = null; // readonly from outside
39

  
39
	private $db_name    = '';
40 40
	private $connected  = false;
41 41

  
42 42
	private $error      = '';
......
65 65
				$this->connected = false;
66 66
				$this->error = mysql_error();
67 67
			} else {
68
				$this->db_name = DB_NAME;
68 69
				$this->connected = true;
69 70
			}
70 71
		}
......
127 128
		return $this->error;
128 129
	}
129 130

  
130
/*
131
 * default Getter
131
/**
132
 * default Getter for some properties
133
 * @param string $sPropertyName
134
 * @return mixed NULL on error or missing property
132 135
 */
133
	public function __get($var_name)
136
	public function __get($sPropertyName)
134 137
	{
135
		if($var_name == 'db_handle')
136
		{
137
			return $this->db_handle;
138
		}
139
		return null;
140
	}
138
		switch ($sPropertyName):
139
			case 'db_handle':
140
			case 'DbHandle':
141
				$retval = $this->db_handle;
142
				break;
143
			case 'db_name':
144
			case 'DbName':
145
				$retval = $this->db_name;
146
				break;
147
			default:
148
				$retval = null;
149
				break;
150
		endswitch;
151
		return $retval;
152
	} // __get()
141 153

  
142 154
/*
143 155
 * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
......
334 346
		$retVal = false;
335 347
		$mysqlVersion = mysql_get_server_info($this->db_handle);
336 348
		$engineValue = (version_compare($mysqlVersion, '5.0') < 0) ? 'Type' : 'Engine';
337
		$sql = "SHOW TABLE STATUS FROM " . DB_NAME . " LIKE '" . $table . "'";
349
		$sql = "SHOW TABLE STATUS FROM " . $this->db_name . " LIKE '" . $table . "'";
338 350
		if(($result = $this->query($sql))) {
339 351
			if(($row = $result->fetchRow(MYSQL_ASSOC))) {
340 352
				$retVal = $row[$engineValue];

Also available in: Unified diff