1 $Id: DBLIB.txt,v 1.4 2000-06-20 03:41:43 wainstead Exp $
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.
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.
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.
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
28 content => array (where each element is a line of the page),
29 created => integer (a number in Unix time since the Epoch),
31 lastmodified => integer (Unix time),
34 refs => array (where each element is a reference)
38 takes: a string, the name of the database
39 returns: a reference to the database (a handle)
43 takes: a reference to the database (handle)
44 returns: the value of the close
47 RetrievePage($dbi, $pagename)
48 takes: db reference, string which is the name of a page
49 returns: a PHP associative array containing the page data
50 (text, version, author, etc)
53 InsertPage($dbi, $pagename, $pagehash)
54 takes: db reference, page name (string), associative array
56 returns: nothing (hmm. It should probably return true/false)
59 IsWikiPage($dbi, $pagename)
60 takes: db reference, string containing page name
61 returns: true or false, if the page already exists
64 InitTitleSearch($dbi, $search)
65 takes: db reference, search string
66 returns: a handle to identify the query and the current position
67 within the result set.
70 TitleSearchNextMatch($dbi, &$pos)
71 takes: db reference, reference to a hash created by
73 returns: the next page name that contains a match to the search term
74 (advances $pos to next result field as well)
77 InitFullSearch($dbi, $search)
78 takes: db reference, string containing search term
79 returns: similar to InitTitleSearch: a handle to identify the
80 query and the current position within the result set.
83 FullSearchNextMatch($dbi, &$pos)
84 takes: db reference, reference to a hash created by
86 returns: an associative array, where:
87 'name' -- contains the page name
88 'hash' -- contains the hash of the page data
89 (advances $pos to next result field as well)