]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - DBLIB.txt
Changed primary key to (pagename, version) in table archive to allow muliple pages...
[SourceForge/phpwiki.git] / DBLIB.txt
1 This is a description of the database interface for PhpWiki. Regardless
2 of what kind of data store is used (RDBMS, DBM files, flat text files)
3 you should be able to write a library that supports that data store.
4
5 A few notes: 
6
7 * While most functions specify a "db reference" as the first value
8   passed in, this can be any kind of data type that your functions
9   know about. For example, in the DBM implementation this is a hash of
10   integers that refer to open database files, but in the MySQL
11   version it's an associative array that contains the DB information.
12
13 * Functions that return the page data must return a hash (associative
14   array) of all the data, where 'content' == the text of the page in Wiki
15   markup, 'version' is an integer representing the version, 'author'
16   the IP address or host name of the previous author and so on. See
17   the next paragraph for a precise description.
18
19 * The data structure. This is commonly named $pagehash in the source
20   code; it's an associative array with values that are integers,
21   strings and arrays (i.e. a heterogenous data structure). Here's a
22   current description:
23
24   $pagehash = {
25      author       => string,
26      content      => array (where each element is a line of the page),
27      created      => integer (a number in Unix time since the Epoch),
28      flags        => integer,
29      lastmodified => integer (also Unix time),
30      pagename     => string,
31      version      => integer
32   };
33
34 The functions are:
35
36       OpenDataBase($dbname)
37       takes:   a string, the name of the database
38       returns: a reference to the database (a handle)
39
40
41       CloseDataBase($dbi)
42       takes:   a reference to the database (handle)
43       returns: the value of the close. For databases with persistent
44                connections, this doesn't return anything.
45
46
47       MakeDBHash($pagename, $pagehash)
48       takes: page name, page array
49       returns: an encoded version of the $pagehash suitable for
50       insertion into the data store. This is an internal helper
51       function used mainly for the RDBMSs.
52
53       MakePageHash($dbhash)
54       takes: an array that came from the database
55       returns: the $pagehash data structure used by the
56       application. This function undoes what MakeDBHash does.
57
58       RetrievePage($dbi, $pagename, $pagestore)
59       takes:   db reference, string which is the name of a page, and a
60       string indicating which store to fetch the page from (live or archive).
61       returns: a PHP associative array containing the page data
62                (text, version, author, etc)
63
64
65       InsertPage($dbi, $pagename, $pagehash)
66       takes:   db reference, page name (string), associative array
67                of all page data
68       returns: nothing (hmm. It should probably return true/false)
69
70       SaveCopyToArchive($dbi, $pagename, $pagehash)
71       Similar to InsertPage but for handling the archive store. The
72       goal here was to separate the two (live db and archive db) in
73       case there were different storage formats (for example, the
74       archive might only store diffs of the pages). However this is
75       not the case in the implementations.
76
77       IsWikiPage($dbi, $pagename)
78       takes:   db reference, string containing page name
79       returns: true or false, if the page already exists in the live db.
80
81       IsInArchive($dbi, $pagename)
82       takes:   db reference, string containing page name
83       returns: true or false, if the page already exists in the archive.
84
85       InitTitleSearch($dbi, $search)
86       takes:   db reference, search string
87       returns: a handle to identify the query and the current position
88                within the result set.
89
90       RemovePage($dbi, $pagename)
91       takes: db reference, name of the page
92       returns: nothing
93       This deletes a page from both the live and archive page stores.
94
95       TitleSearchNextMatch($dbi, &$pos)
96       takes:   db reference, reference to a hash created by
97                InitTitleSearch
98       returns: the next page name that contains a match to the search term
99                (advances $pos to next result field as well)
100
101       MakeSQLSearchClause($search, $column)
102       takes: a search string, column name
103       returns: a SQL query string suitable for a database query
104
105       InitFullSearch($dbi, $search)
106       takes:   db reference, string containing search term
107       returns: similar to InitTitleSearch: a handle to identify the
108                query and the current position within the result set.
109
110
111       FullSearchNextMatch($dbi, &$pos)
112       takes:   db reference, reference to a hash created by
113                InitFullSearch
114       returns: an associative array, where:
115                   'name' -- contains the page name
116                   'hash' -- contains the hash of the page data
117                (advances $pos to next result field as well)
118
119
120       IncreaseHitCount($dbi, $pagename)
121       takes: db reference, string (name of a page)
122       returns: nothing (MySQL implementation returns the last result
123                set but it is not used by the caller)
124                
125
126       GetHitCount($dbi, $pagename)
127       takes: db reference, string (page name)
128       returns: an integer, the number of hits the page has received
129
130
131       InitMostPopular($dbi, $limit)
132       takes: a db reference and an integer, which is the limit of the
133              number of pages you want returned.
134       returns: the result set from the query
135
136
137       MostPopularNextMatch($dbi, $res)
138       takes: db reference, the result set returned by InitMostPopular
139       returns: the next row from the result set, as a PHP array type
140
141       GetAllWikiPageNames($dbi)
142       takes: db reference
143       returns: an array containing all page names
144
145       GetWikiPageLinks($dbi, $pagename)
146       takes: db reference, page name
147       returns: a two-dimensional array containing outbound links
148       ordered by score desc ('out'); inbound links ordered by score
149       desc ('in'); inbound or outbound links ordered by most number of
150       page views ('popular').
151
152       SetWikiPageLinks($dbi, $pagename, $linklist)
153       takes: db reference, page name, list of pages linking to this
154       one
155       This deletes the existing list of linking pages and inserts all
156       the page names in $linklist.
157
158 $Id: DBLIB.txt,v 1.9 2001-02-17 05:35:56 dairiki Exp $
159