]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/SQL.php
* revert to the wikidb ref passing. there's no memory abuse there.
[SourceForge/phpwiki.git] / lib / WikiDB / SQL.php
1 <?php rcs_id('$Id: SQL.php,v 1.9 2004-11-09 17:11:16 rurban Exp $');
2
3 require_once('lib/WikiDB.php');
4 //require_once('lib/WikiDB/backend/PearDB.php');
5 //require_once('DB.php'); // Always favor use our local pear copy
6
7 /**
8  *
9  */
10 class WikiDB_SQL extends WikiDB
11 {
12     function WikiDB_SQL ($dbparams) {
13         $backend_type = 'PearDB';
14         if (is_array($dbparams['dsn']))
15             $backend_type = $dbparams['dsn']['phptype'];
16         elseif (preg_match('/^(\w+):/', $dbparams['dsn'], $m))
17             $backend_type = $m[1];
18         include_once ("lib/WikiDB/backend/PearDB_".$backend_type.".php");
19         $backend_class = "WikiDB_backend_PearDB_".$backend_type;
20         $backend = & new $backend_class($dbparams);
21         $this->_iwpcache = array();
22         
23         $this->WikiDB($backend, $dbparams);
24     }
25     
26     function view_dsn ($dsn = false) {
27         if (!$dsn)
28             $dsninfo = DB::parseDSN($GLOBALS['DBParams']['dsn']);
29         else
30             $dsninfo = DB::parseDSN($dsn);
31         return sprintf("%s://%s:<not displayed>@%s/%s",
32                        $dsninfo['phptype'],
33                        $dsninfo['username'],
34                        $dsninfo['hostspec'],
35                        $dsninfo['database']
36                        );
37     }
38
39     
40     /**
41      * Determine whether page exists (in non-default form).
42      * @see WikiDB::isWikiPage for the slow generic version
43      */
44     function isWikiPage ($pagename) {
45         $pagename = (string) $pagename;
46         if ($pagename === '') return false;
47         //if (empty($this->_iwpcache)) {  $this->_iwpcache = array();  }
48         if (!array_key_exists($pagename, $this->_iwpcache)) {
49             $this->_iwpcache[$pagename] = $this->_backend->is_wiki_page($pagename);
50         }
51         return $this->_iwpcache[$pagename];
52     }
53 };
54
55   
56 // For emacs users
57 // Local Variables:
58 // mode: php
59 // tab-width: 8
60 // c-basic-offset: 4
61 // c-hanging-comment-ender-p: nil
62 // indent-tabs-mode: nil
63 // End:
64
65 ?>