Subversion Repositories Sites.tela-botanica.org

Rev

Rev 609 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
420 florian 1
<?php
2
require_once('wakka.config.php');
3
 
4
// Une classe minimal wiki pour l'acces à la base de donnée
5
 
6
class Wiki
7
{
8
	var $dblink;
9
	var $VERSION;
10
 
11
	// constructor
12
	function Wiki($config)
13
	{
14
		$this->config = $config;
15
		// some host do not allow mysql_pconnect
16
		$this->dblink = @mysql_connect (
17
			$this->config["mysql_host"],
18
			$this->config["mysql_user"],
19
			$this->config["mysql_password"]);
20
		if ($this->dblink)
21
		{
22
			if (!@mysql_select_db($this->config["mysql_database"], $this->dblink))
23
			{
24
				@mysql_close($this->dblink);
25
				$this->dblink = false;
26
			}
27
		}
28
		$this->VERSION = WAKKA_VERSION;
29
 
30
	}
31
 
32
 
33
	// DATABASE
34
	function Query($query)
35
	{
36
		if (!$result = mysql_query($query, $this->dblink))
37
		{
38
			ob_end_clean();
39
			die("Query failed: ".$query." (".mysql_error().")");
40
		}
41
		return $result;
42
	}
43
	function LoadSingle($query) { if ($data = $this->LoadAll($query)) return $data[0]; }
44
	function LoadAll($query)
45
	{
46
	$data=array();
47
	if ($r = $this->Query($query))
48
		{
49
			while ($row = mysql_fetch_assoc($r)) $data[] = $row;
50
			mysql_free_result($r);
51
		}
52
		return $data;
53
	}
54
 
55
}
56
?>