]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - DBLIB.txt
This is the first draft of the contract for the database interface. When
[SourceForge/phpwiki.git] / DBLIB.txt
1 $Id: DBLIB.txt,v 1.1 2000-06-05 20:54:42 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 'text' == 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 source code for the full listing.
20
21
22       OpenDataBase($dbname)
23       takes:   a string, the name of the database
24       returns: a reference to the database (a handle)
25
26
27       CloseDataBase($dbi)
28       takes:   a reference to the database (handle)
29       returns: the value of the close
30
31
32       RetrievePage($dbi, $pagename)
33       takes:   db reference, string which is the name of a page
34       returns: a PHP associative array containing the page data
35                (text, version, prvious author, etc)
36
37
38       InsertPage($dbi, $pagename, $pagehash)
39       takes:   db reference, page name (string), associative array
40                of all page data
41       returns: nothing (hmm. It should probably return true/false)
42
43
44       IsWikiPage($dbi, $pagename)
45       takes:   db reference, string containing page name
46       returns: true or false, if the page already exists
47
48
49       InitTitleSearch($dbi, $search)
50       takes:   db reference, search string
51       returns: a hash with two keys:
52                  'search' -- the search string passed in
53                  'key'    -- the first page name returned from the database
54
55
56       TitleSearchNextMatch($dbi, &$pos)
57       takes:   db reference, reference to a hash created by
58                InitTitleSearch
59       returns: the next page name that contains a match to the search term
60
61
62       InitFullSearch($dbi, $search)
63       takes:   db reference, string containing search term
64       returns: this calls InitTitleSearch and returns that result
65
66
67       FullSearchNextMatch($dbi, &$pos)
68       takes:   db reference, reference to a hash created by
69                InitFullSearch
70       returns: an associative array, where:
71                   'name' -- contains the page name
72                   'hash' -- contains the hash of the page data