]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - DBLIB.txt
Added new markup rules for ordered and unordered lists.
[SourceForge/phpwiki.git] / DBLIB.txt
1 $Id: DBLIB.txt,v 1.6 2000-06-30 00:44:23 wainstead Exp $
2
3 This is a description of the database interface for PhpWiki. Regardless
4 of what kind of data store is used (RDBMS, DBM files, flat text files)
5 you should be able to write a library that supports that data store.
6
7 A few notes: 
8
9 * While most functions specify a "db reference" as the first value
10   passed in, this can be any kind of data type that your functions
11   know about. For example, in the DBM implementation this is an
12   integer that refers to an open database handle, but in the MySQL
13   version it's an associative array that contains the DB information.
14
15 * Functions that return the page data must return a hash (associative
16   array) of all the data, where 'content' == the text of the page in Wiki
17   markup, 'version' is an integer representing the version, 'author'
18   the IP address or host name of the previous author and so on. See
19   the next paragraph for a precise description.
20
21 * The data structure. This is commonly named $pagehash in the source
22   code; it's an associative array with values that are integers,
23   strings and arrays (i.e. a heterogenous data structure). Here's a
24   current description:
25
26   $pagehash = {
27      author       => string,
28      content      => array (where each element is a line of the page),
29      created      => integer (a number in Unix time since the Epoch),
30      flags        => integer,
31      lastmodified => integer (also Unix time),
32      pagename     => string,
33      version      => integer,
34      refs         => array (where each element is a reference)
35   };
36
37 The functions are:
38
39       OpenDataBase($dbname)
40       takes:   a string, the name of the database
41       returns: a reference to the database (a handle)
42
43
44       CloseDataBase($dbi)
45       takes:   a reference to the database (handle)
46       returns: the value of the close. For databases with persistent
47                connections, this doesn't return anything.
48
49
50       RetrievePage($dbi, $pagename)
51       takes:   db reference, string which is the name of a page
52       returns: a PHP associative array containing the page data
53                (text, version, author, etc)
54
55
56       InsertPage($dbi, $pagename, $pagehash)
57       takes:   db reference, page name (string), associative array
58                of all page data
59       returns: nothing (hmm. It should probably return true/false)
60
61
62       IsWikiPage($dbi, $pagename)
63       takes:   db reference, string containing page name
64       returns: true or false, if the page already exists
65
66
67       InitTitleSearch($dbi, $search)
68       takes:   db reference, search string
69       returns: a handle to identify the query and the current position
70                within the result set.
71
72
73       TitleSearchNextMatch($dbi, &$pos)
74       takes:   db reference, reference to a hash created by
75                InitTitleSearch
76       returns: the next page name that contains a match to the search term
77                (advances $pos to next result field as well)
78
79
80       InitFullSearch($dbi, $search)
81       takes:   db reference, string containing search term
82       returns: similar to InitTitleSearch: a handle to identify the
83                query and the current position within the result set.
84
85
86       FullSearchNextMatch($dbi, &$pos)
87       takes:   db reference, reference to a hash created by
88                InitFullSearch
89       returns: an associative array, where:
90                   'name' -- contains the page name
91                   'hash' -- contains the hash of the page data
92                (advances $pos to next result field as well)
93
94
95       IncreaseHitCount($dbi, $pagename)
96       takes: db reference, string (name of a page)
97       returns: nothing (MySQL implementation returns the last result
98                set but it is not used by the caller)
99                
100
101       GetHitCount($dbi, $pagename)
102       takes: db reference, string (page name)
103       returns: an integer, the number of hits the page has received
104
105
106       InitMostPopular($dbi, $limit)
107       takes: a db reference and an integer, which is the limit of the
108              number of pages you want returned.
109       returns: the result set from the query
110
111
112       MostPopularNextMatch($dbi, $res)
113       takes: db reference, the result set returned by InitMostPopular
114       returns: the next row from the result set, as a PHP array type