Location: PHPKode > projects > Zitro-Stats > include/db_mysql.inc.php
<?php

	// ANTIHACK
	defined('INSTATS') OR die();

	class sql {
		function sql() {
			global $options;
			if($options['SQL_PERSIST']) {
				$this->connection = @mysql_pconnect($options['SQL_SERVER'],$options['SQL_USER'],$options['SQL_PASSWORD'])
					OR die("error mysql_pconnect('".htmlentities($options['SQL_SERVER'])."','".htmlentities($options['SQL_USER'])."','".($options['SQL_PASSWORD']?"*****":"")."')");
			} else {
				$this->connection = @mysql_connect($options['SQL_SERVER'],$options['SQL_USER'],$options['SQL_PASSWORD'])
					OR die("error mysql_connect('".htmlentities($options['SQL_SERVER'])."','".htmlentities($options['SQL_USER'])."','".($options['SQL_PASSWORD']?"*****":"")."')");
			}
			if(!mysql_select_db($options['SQL_DATABASE'])) {
				if(defined('INSTALL'))
					$this->query("CREATE DATABASE IF NOT EXISTS `".mysql_real_escape_string($options['SQL_DATABASE'],$this->connection)."`");
				else
					die("error mysql_select_db('".htmlentities($options['SQL_DATABASE'])."') on '".htmlentities($options['SQL_SERVER'])."'");
			}
		}

		function query($query) {
			list($usec, $sec) = explode(" ", microtime());
			//fwrite(fopen("log.sql",'a'),date("# Y-m-d h:i:s ",$sec).substr($usec,2,6)."\n".trim(str_replace("\t","  ",$query))."\n\n");
			if($result = @mysql_query($query,$this->connection)) return $result;
			die("error mysql_query('".nl2br(htmlentities($query))."')<br />".mysql_error($this->connection));
		}

		function fetchrow($result) {
			return mysql_fetch_row($result);
		}

		function fetcharray($result) {
			return mysql_fetch_array($result,MYSQL_ASSOC);
		}

		function numrows($result) {
			return mysql_num_rows($result);
		}

		function affrows() {
			return mysql_affected_rows($this->connection);
		}

		function lastid() {
			return mysql_insert_id($this->connection);
		}

		function escape($data) {
			return is_numeric($data) ? $data : mysql_real_escape_string($data,$this->connection);
		}
	}

?>
Return current item: Zitro-Stats