1 $Id: DBLIB.txt,v 1.6 2000-06-30 00:44:23 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 '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.
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 (also Unix time),
34 refs => array (where each element is a reference)
40 takes: a string, the name of the database
41 returns: a reference to the database (a handle)
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.
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)
56 InsertPage($dbi, $pagename, $pagehash)
57 takes: db reference, page name (string), associative array
59 returns: nothing (hmm. It should probably return true/false)
62 IsWikiPage($dbi, $pagename)
63 takes: db reference, string containing page name
64 returns: true or false, if the page already exists
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.
73 TitleSearchNextMatch($dbi, &$pos)
74 takes: db reference, reference to a hash created by
76 returns: the next page name that contains a match to the search term
77 (advances $pos to next result field as well)
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.
86 FullSearchNextMatch($dbi, &$pos)
87 takes: db reference, reference to a hash created by
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)
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)
101 GetHitCount($dbi, $pagename)
102 takes: db reference, string (page name)
103 returns: an integer, the number of hits the page has received
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
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