source: temp/test-xoops.ec-cube.net/html/class/database/database.php @ 405

Revision 405, 4.3 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: database.php,v 1.3 2006/05/01 02:37:24 onokazu Exp $
3// database.php - defines abstract database wrapper class
4//  ------------------------------------------------------------------------ //
5//                XOOPS - PHP Content Management System                      //
6//                    Copyright (c) 2000 XOOPS.org                           //
7//                       <http://www.xoops.org/>                             //
8//  ------------------------------------------------------------------------ //
9//  This program is free software; you can redistribute it and/or modify     //
10//  it under the terms of the GNU General Public License as published by     //
11//  the Free Software Foundation; either version 2 of the License, or        //
12//  (at your option) any later version.                                      //
13//                                                                           //
14//  You may not change or alter any portion of this comment or credits       //
15//  of supporting developers from this source code or any supporting         //
16//  source code which is considered copyrighted (c) material of the          //
17//  original comment or credit authors.                                      //
18//                                                                           //
19//  This program is distributed in the hope that it will be useful,          //
20//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
21//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
22//  GNU General Public License for more details.                             //
23//                                                                           //
24//  You should have received a copy of the GNU General Public License        //
25//  along with this program; if not, write to the Free Software              //
26//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
27//  ------------------------------------------------------------------------ //
28/**
29 * @package     kernel
30 * @subpackage  database
31 *
32 * @author      Kazumi Ono  <[email protected]>
33 * @copyright   copyright (c) 2000-2003 XOOPS.org
34 */
35
36/**
37 * make sure this is only included once!
38 */
39if ( !defined("XOOPS_C_DATABASE_INCLUDED") ) {
40    define("XOOPS_C_DATABASE_INCLUDED",1);
41
42/**
43 * Abstract base class for Database access classes
44 *
45 * @abstract
46 *
47 * @author Kazumi Ono <[email protected]>
48 * @copyright copyright (c) 2000-2003 XOOPS.org
49 *
50 * @package kernel
51 * @subpackage database
52 */
53class XoopsDatabase
54    {
55        /**
56         * Prefix for tables in the database
57         * @var string
58         */
59        var $prefix = '';
60        /**
61         * reference to a {@link XoopsLogger} object
62         * @see XoopsLogger
63         * @var object XoopsLogger
64         */
65        var $logger;
66
67        /**
68         * constructor
69         *
70         * will always fail, because this is an abstract class!
71         */
72        function XoopsDatabase()
73        {
74            // exit("Cannot instantiate this class directly");
75        }
76
77        /**
78         * assign a {@link XoopsLogger} object to the database
79         *
80         * @see XoopsLogger
81         * @param object $logger reference to a {@link XoopsLogger} object
82         */
83        function setLogger(&$logger)
84        {
85            $this->logger =& $logger;
86        }
87
88        /**
89         * set the prefix for tables in the database
90         *
91         * @param string $value table prefix
92         */
93        function setPrefix($value)
94        {
95            $this->prefix = $value;
96        }
97       
98        /**
99         * attach the prefix.'_' to a given tablename
100         *
101         * if tablename is empty, only prefix will be returned
102         *
103         * @param string $tablename tablename
104         * @return string prefixed tablename, just prefix if tablename is empty
105         */
106        function prefix($tablename='')
107        {
108            if ( $tablename != '' ) {
109                return $this->prefix .'_'. $tablename;
110            } else {
111                return $this->prefix;
112            }
113        }
114    }
115}
116
117
118/**
119 * Only for backward compatibility
120 *
121 * @deprecated
122 */
123class Database
124{
125
126    function &getInstance()
127    {
128        $ret =& XoopsDatabaseFactory::getDatabaseConnection();
129        return $ret;
130    }
131}
132
133?>
Note: See TracBrowser for help on using the repository browser.