Location: PHPKode > projects > Todo Manager > todo/classes/database.class.php
<?php
require_once $_SERVER["DOCUMENT_ROOT"]."/".FOLDER."/library/util.lib.php";

class Database {
	var $conn;
	
	function Database($database_name, $user_name, $password) {
		$this->conn = mysql_connect("localhost", $user_name, $password);
		mysql_select_db($database_name, $this->conn);
	}
	
	function getConnection() {
		return $this->conn;
	}
	
	function getResult($sql) {
		return mysql_query($sql, $this->conn);
	}
	
	function getRow($result) {
		return mysql_fetch_array($result);
	}
	
	function getList($sql) {
		$result = $this->getResult($sql);
		$list = array();
		while($row = $this->getRow($result))
			array_push($list, $row);
		return $list;
	}
	
	function execute($sql) {
		mysql_query($sql);
		return mysql_affected_rows($this->conn);
	}
	
	function getNumRows($result) {
		return mysql_num_rows($result);
	}
	
	function getInsertId() {
		return mysql_insert_id($this->conn);
	}
	
	function quote($param) {
		if (util_empty($param))
			return "NULL";
		return "'".mysql_real_escape_string($param, $this->conn)."'";
	}
	
	function quotename($name) {
		return "`".preg_replace("/[^\w]/", NULL, $name)."`";
	}
}
?>
Return current item: Todo Manager