Location: PHPKode > projects > ZefieCast > zefiecast_pub/classes/mysql.php
<?

// MySQL Class for ZefieCast v1.0

class MySQL {

	var $mysqlconn;
	var $mysqlquery;

	function connect($db,$user,$pass,$host = "localhost")
	{
		$mysqlconn = mysql_connect ($host,$user,$pass);
		$this->mysqlconn = $mysqlconn;

		if ($mysqlconn) {
			$this->selectDB($db);
			return true;
		} else {
			$this->doFail();
		}
	}

	function selectDB($db)
	{
		mysql_select_db($db);
	}

	function close()
	{
		mysql_close($this->mysqlconn);
	}

	function query($query)
	{
		// echo $query."\n";
		$mysqlquery =  mysql_query($query,$this->mysqlconn);
                if ($mysqlquery) {
                        $this->mysqlquery = $mysqlquery;
                        return true;
                } else {
			 $this->doFail();
                }
	}		
	
	function count()
	{
                $mysqlres =  mysql_num_rows($this->mysqlquery);
                return $mysqlres;
	}

        function row()
        {
                $mysqlres =  mysql_fetch_row($this->mysqlquery);
                if ($mysqlres) {
                        return $mysqlres;
                } else {
			$this->doFail();
                }
        }

	function escape($string) {
		return mysql_escape_string($string);
	}

	function errorMsg() {
		return mysql_error($this->mysqlconn);
	}
	
	function doFail() {
		$error = $this->errorMsg();
		if (!$error) {
			return false;
		}
		die($error."\n");
	}

	function getConfig() {
		global $mysql, $artistplay, $titleplay, $albumplay, $queuesongs, $enablereq, $artistreq, $titlereq, $albumreq, $reqtime, $reqlimit, $filters;

		$mysql->query("SELECT * FROM config");
		$data = $mysql->row();
		$artistplay = $data[1];
		$titleplay = $data[2];
		$albumplay = $data[3];
		$queuesongs = $data[4];
		$enablereq = $data[5];
		$artistreq = $data[6];
		$titlereq = $data[7];
		$albumreq = $data[8];
		$reqtime = $data[9];
		$reqlimit = $data[10];
		$filters = $data[11];
	}

}

?>
Return current item: ZefieCast