Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
// +----------------------------------------------------------------------+
3
// | PHP Version 4                                                        |
4
// +----------------------------------------------------------------------+
5
// | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox,                 |
6
// | Stig. S. Bakken, Lukas Smith                                         |
7
// | All rights reserved.                                                 |
8
// +----------------------------------------------------------------------+
9
// | MDB is a merge of PEAR DB and Metabases that provides a unified DB   |
10
// | API as well as database abstraction for PHP applications.            |
11
// | This LICENSE is in the BSD license style.                            |
12
// |                                                                      |
13
// | Redistribution and use in source and binary forms, with or without   |
14
// | modification, are permitted provided that the following conditions   |
15
// | are met:                                                             |
16
// |                                                                      |
17
// | Redistributions of source code must retain the above copyright       |
18
// | notice, this list of conditions and the following disclaimer.        |
19
// |                                                                      |
20
// | Redistributions in binary form must reproduce the above copyright    |
21
// | notice, this list of conditions and the following disclaimer in the  |
22
// | documentation and/or other materials provided with the distribution. |
23
// |                                                                      |
24
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,    |
25
// | Lukas Smith nor the names of his contributors may be used to endorse |
26
// | or promote products derived from this software without specific prior|
27
// | written permission.                                                  |
28
// |                                                                      |
29
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
30
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
31
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
32
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
33
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          |
34
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
35
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
36
// |  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  |
37
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          |
38
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
39
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          |
40
// | POSSIBILITY OF SUCH DAMAGE.                                          |
41
// +----------------------------------------------------------------------+
42
// | Author: YOUR NAME <YOUR EMAIL>                                       |
43
// +----------------------------------------------------------------------+
44
//
45
// $Id: Modules_Manager_skeleton.php,v 1.5.4.1 2004/01/08 13:43:05 lsmith Exp $
46
//
47
 
48
// This is just a skeleton MDB driver.
49
 
50
// In each of the listed methods I have added comments that tell you where
51
// to look for a "reference" implementation.
52
// Many of the methods below are taken from Metabase. Most of the methods
53
// marked as "new in MDB" are actually taken from the latest beta files of
54
// Metabase. However these beta files only include a version for MySQL.
55
// Some of these methods have been expanded or changed slightly in MDB.
56
// Looking in the relevant MDB Wrapper should give you some pointers, some
57
// other difference you will only discover by looking at one of the existing
58
// MDB driver or the common implementation in common.php.
59
// One thing that will definately have to be modified in all "reference"
60
// implementations of Metabase methods is the error handling.
61
// Anyways don't worry if you are having problems: Lukas Smith is here to help!
62
 
63
if(!defined('MDB_MANAGER_XXX_INCLUDED'))
64
{
65
    define('MDB_MANAGER_XXX_INCLUDED',1);
66
 
67
require_once('MDB/Modules/Manager/Common.php');
68
 
69
/**
70
 * MDB Xxx driver for the management modules
71
 *
72
 * @package MDB
73
 * @category Database
74
 * @author  YOUR NAME <YOUR EMAIL>
75
 */
76
class MDB_Manager_xxx_ extends MDB_Manager_Common
77
{
78
    // }}}
79
    // {{{ createDatabase()
80
 
81
    /**
82
     * create a new database
83
     *
84
     * @param object    $dbs        database object that is extended by this class
85
     * @param string $name name of the database that should be created
86
     * @return mixed MDB_OK on success, a MDB error on failure
87
     * @access public
88
     */
89
    function createDatabase(&$db, $name)
90
    {
91
        // take this from the corresponding Metabase driver: CreateDatabase()
92
    }
93
 
94
    // }}}
95
    // {{{ dropDatabase()
96
 
97
    /**
98
     * drop an existing database
99
     *
100
     * @param object    $dbs        database object that is extended by this class
101
     * @param string $name name of the database that should be dropped
102
     * @return mixed MDB_OK on success, a MDB error on failure
103
     * @access public
104
     */
105
    function dropDatabase(&$db, $name)
106
    {
107
        // take this from the corresponding Metabase driver: DropDatabase()
108
    }
109
 
110
    // }}}
111
    // {{{ createTable()
112
 
113
    /**
114
     * create a new table
115
     *
116
     * @param object    $dbs        database object that is extended by this class
117
     * @param string $name     Name of the database that should be created
118
     * @param array $fields Associative array that contains the definition of each field of the new table
119
     *                        The indexes of the array entries are the names of the fields of the table an
120
     *                        the array entry values are associative arrays like those that are meant to be
121
     *                         passed with the field definitions to get[Type]Declaration() functions.
122
     *
123
     *                        Example
124
     *                        array(
125
     *
126
     *                            'id' => array(
127
     *                                'type' => 'integer',
128
     *                                'unsigned' => 1
129
     *                                'notnull' => 1
130
     *                                'default' => 0
131
     *                            ),
132
     *                            'name' => array(
133
     *                                'type' => 'text',
134
     *                                'length' => 12
135
     *                            ),
136
     *                            'password' => array(
137
     *                                'type' => 'text',
138
     *                                'length' => 12
139
     *                            )
140
     *                        );
141
     * @return mixed MDB_OK on success, a MDB error on failure
142
     * @access public
143
     */
144
    function createTable(&$db, $name, $fields)
145
    {
146
        // take this from the corresponding Metabase driver: CreateTable()
147
    }
148
 
149
    // }}}
150
    // {{{ alterTable()
151
 
152
    /**
153
     * alter an existing table
154
     *
155
     * @param object    $dbs        database object that is extended by this class
156
     * @param string $name         name of the table that is intended to be changed.
157
     * @param array $changes     associative array that contains the details of each type
158
     *                             of change that is intended to be performed. The types of
159
     *                             changes that are currently supported are defined as follows:
160
     *
161
     *                             name
162
     *
163
     *                                New name for the table.
164
     *
165
     *                            AddedFields
166
     *
167
     *                                Associative array with the names of fields to be added as
168
     *                                 indexes of the array. The value of each entry of the array
169
     *                                 should be set to another associative array with the properties
170
     *                                 of the fields to be added. The properties of the fields should
171
     *                                 be the same as defined by the Metabase parser.
172
     *
173
     *                                Additionally, there should be an entry named Declaration that
174
     *                                 is expected to contain the portion of the field declaration already
175
     *                                 in DBMS specific SQL code as it is used in the CREATE TABLE statement.
176
     *
177
     *                            RemovedFields
178
     *
179
     *                                Associative array with the names of fields to be removed as indexes
180
     *                                 of the array. Currently the values assigned to each entry are ignored.
181
     *                                 An empty array should be used for future compatibility.
182
     *
183
     *                            RenamedFields
184
     *
185
     *                                Associative array with the names of fields to be renamed as indexes
186
     *                                 of the array. The value of each entry of the array should be set to
187
     *                                 another associative array with the entry named name with the new
188
     *                                 field name and the entry named Declaration that is expected to contain
189
     *                                 the portion of the field declaration already in DBMS specific SQL code
190
     *                                 as it is used in the CREATE TABLE statement.
191
     *
192
     *                            ChangedFields
193
     *
194
     *                                Associative array with the names of the fields to be changed as indexes
195
     *                                 of the array. Keep in mind that if it is intended to change either the
196
     *                                 name of a field and any other properties, the ChangedFields array entries
197
     *                                 should have the new names of the fields as array indexes.
198
     *
199
     *                                The value of each entry of the array should be set to another associative
200
     *                                 array with the properties of the fields to that are meant to be changed as
201
     *                                 array entries. These entries should be assigned to the new values of the
202
     *                                 respective properties. The properties of the fields should be the same
203
     *                                 as defined by the Metabase parser.
204
     *
205
     *                                If the default property is meant to be added, removed or changed, there
206
     *                                 should also be an entry with index ChangedDefault assigned to 1. Similarly,
207
     *                                 if the notnull constraint is to be added or removed, there should also be
208
     *                                 an entry with index ChangedNotNull assigned to 1.
209
     *
210
     *                                Additionally, there should be an entry named Declaration that is expected
211
     *                                 to contain the portion of the field changed declaration already in DBMS
212
     *                                 specific SQL code as it is used in the CREATE TABLE statement.
213
     *                            Example
214
     *                                array(
215
     *                                    'name' => 'userlist',
216
     *                                    'AddedFields' => array(
217
     *                                        'quota' => array(
218
     *                                            'type' => 'integer',
219
     *                                            'unsigned' => 1
220
     *                                            'Declaration' => 'quota INT'
221
     *                                        )
222
     *                                    ),
223
     *                                    'RemovedFields' => array(
224
     *                                        'file_limit' => array(),
225
     *                                        'time_limit' => array()
226
     *                                        ),
227
     *                                    'ChangedFields' => array(
228
     *                                        'gender' => array(
229
     *                                            'default' => 'M',
230
     *                                            'ChangeDefault' => 1,
231
     *                                            'Declaration' => "gender CHAR(1) DEFAULT 'M'"
232
     *                                        )
233
     *                                    ),
234
     *                                    'RenamedFields' => array(
235
     *                                        'sex' => array(
236
     *                                            'name' => 'gender',
237
     *                                            'Declaration' => "gender CHAR(1) DEFAULT 'M'"
238
     *                                        )
239
     *                                    )
240
     *                                )
241
     *
242
     * @param boolean $check     indicates whether the function should just check if the DBMS driver
243
     *                             can perform the requested table alterations if the value is true or
244
     *                             actually perform them otherwise.
245
     * @access public
246
     *
247
      * @return mixed MDB_OK on success, a MDB error on failure
248
     */
249
    function alterTable(&$db, $name, $changes, $check)
250
    {
251
        // take this from the corresponding Metabase driver: AlterTable()
252
    }
253
 
254
    // }}}
255
    // {{{ listDatabases()
256
 
257
    /**
258
     * list all databases
259
     *
260
     * @param object    $dbs        database object that is extended by this class
261
     * @return mixed data array on success, a MDB error on failure
262
     * @access public
263
     */
264
    function listDatabases(&$db)
265
    {
266
        // new in MDB
267
    }
268
 
269
    // }}}
270
    // {{{ listUsers()
271
 
272
    /**
273
     * list all users
274
     *
275
     * @param object    $dbs        database object that is extended by this class
276
     * @return mixed data array on success, a MDB error on failure
277
     * @access public
278
     */
279
    function listUsers(&$db)
280
    {
281
        // new in MDB
282
    }
283
 
284
    // }}}
285
    // {{{ listTables()
286
 
287
    /**
288
     * list all tables in the current database
289
     *
290
     * @param object    $dbs        database object that is extended by this class
291
     * @return mixed data array on success, a MDB error on failure
292
     * @access public
293
     */
294
    function listTables(&$db)
295
    {
296
        // new in MDB
297
    }
298
 
299
    // }}}
300
    // {{{ listTableFields()
301
 
302
    /**
303
     * list all fields in a tables in the current database
304
     *
305
     * @param object    $dbs        database object that is extended by this class
306
     * @param string $table name of table that should be used in method
307
     * @return mixed data array on success, a MDB error on failure
308
     * @access public
309
     */
310
    function listTableFields(&$db, $table)
311
    {
312
        // new in MDB
313
    }
314
 
315
    // }}}
316
    // {{{ getTableFieldDefinition()
317
 
318
    /**
319
     * get the stucture of a field into an array
320
     *
321
     * @param object    $dbs        database object that is extended by this class
322
     * @param string    $table         name of table that should be used in method
323
     * @param string    $field_name     name of field that should be used in method
324
     * @return mixed data array on success, a MDB error on failure
325
     * @access public
326
     */
327
    function getTableFieldDefinition(&$db, $table, $field_name)
328
    {
329
        // new in MDB
330
    }
331
 
332
    // }}}
333
    // {{{ createIndex()
334
 
335
    /**
336
     * get the stucture of a field into an array
337
     *
338
     * @param object    $dbs        database object that is extended by this class
339
     * @param string    $table         name of the table on which the index is to be created
340
     * @param string    $name         name of the index to be created
341
     * @param array     $definition        associative array that defines properties of the index to be created.
342
     *                                 Currently, only one property named FIELDS is supported. This property
343
     *                                 is also an associative with the names of the index fields as array
344
     *                                 indexes. Each entry of this array is set to another type of associative
345
     *                                 array that specifies properties of the index that are specific to
346
     *                                 each field.
347
     *
348
     *                                Currently, only the sorting property is supported. It should be used
349
     *                                 to define the sorting direction of the index. It may be set to either
350
     *                                 ascending or descending.
351
     *
352
     *                                Not all DBMS support index sorting direction configuration. The DBMS
353
     *                                 drivers of those that do not support it ignore this property. Use the
354
     *                                 function support() to determine whether the DBMS driver can manage indexes.
355
 
356
     *                                 Example
357
     *                                    array(
358
     *                                        'FIELDS' => array(
359
     *                                            'user_name' => array(
360
     *                                                'sorting' => 'ascending'
361
     *                                            ),
362
     *                                            'last_login' => array()
363
     *                                        )
364
     *                                    )
365
     * @return mixed MDB_OK on success, a MDB error on failure
366
     * @access public
367
     */
368
    function createIndex(&$db, $table, $name, $definition)
369
    {
370
        // take this from the corresponding Metabase driver: CreateIndex()
371
    }
372
 
373
    // }}}
374
    // {{{ dropIndex()
375
 
376
    /**
377
     * drop existing index
378
     *
379
     * @param object    $dbs        database object that is extended by this class
380
     * @param string    $table         name of table that should be used in method
381
     * @param string    $name         name of the index to be dropped
382
     * @return mixed MDB_OK on success, a MDB error on failure
383
     * @access public
384
     */
385
    function dropIndex(&$db, $table, $name)
386
    {
387
        // take this from the corresponding Metabase driver: DropIndex()
388
    }
389
 
390
    // }}}
391
    // {{{ listTableIndexes()
392
 
393
    /**
394
     * list all indexes in a table
395
     *
396
     * @param object    $dbs        database object that is extended by this class
397
     * @param string    $table      name of table that should be used in method
398
     * @return mixed data array on success, a MDB error on failure
399
     * @access public
400
     */
401
    function listTableIndexes(&$db, $table)
402
    {
403
        // new in MDB
404
    }
405
 
406
    // }}}
407
    // {{{ getTableIndexDefinition()
408
 
409
    /**
410
     * get the stucture of an index into an array
411
     *
412
     * @param object    $dbs        database object that is extended by this class
413
     * @param string    $table      name of table that should be used in method
414
     * @param string    $index_name name of index that should be used in method
415
     * @return mixed data array on success, a MDB error on failure
416
     * @access public
417
     */
418
    function getTableIndexDefinition(&$db, $table, $index_name)
419
    {
420
        // new in MDB
421
    }
422
 
423
    // }}}
424
    // {{{ createSequence()
425
 
426
    /**
427
     * create sequence
428
     *
429
     * @param object    $dbs        database object that is extended by this class
430
     * @param string    $seq_name     name of the sequence to be created
431
     * @param string    $start         start value of the sequence; default is 1
432
     * @return mixed MDB_OK on success, a MDB error on failure
433
     * @access public
434
     */
435
    function createSequence(&$db, $seq_name, $start)
436
    {
437
        // take this from the corresponding Metabase driver: CreateSequence()
438
    }
439
 
440
    // }}}
441
    // {{{ dropSequence()
442
 
443
    /**
444
     * drop existing sequence
445
     *
446
     * @param object    $dbs        database object that is extended by this class
447
     * @param string    $seq_name     name of the sequence to be dropped
448
     * @return mixed MDB_OK on success, a MDB error on failure
449
     * @access public
450
     */
451
    function dropSequence(&$db, $seq_name)
452
    {
453
        // take this from the corresponding Metabase driver: DropSequence()
454
    }
455
 
456
    // }}}
457
    // {{{ listSequences()
458
 
459
    /**
460
     * list all sequences in the current database
461
     *
462
     * @param object    $dbs        database object that is extended by this class
463
     * @return mixed data array on success, a MDB error on failure
464
     * @access public
465
     */
466
    function listSequences(&$db)
467
    {
468
        // new in MDB
469
    }
470
 
471
    // }}}
472
    // {{{ getSequenceDefinition()
473
 
474
    /**
475
     * get the stucture of a sequence into an array
476
     *
477
     * @param object    $dbs        database object that is extended by this class
478
     * @param string    $sequence   name of sequence that should be used in method
479
     * @return mixed data array on success, a MDB error on failure
480
     * @access public
481
     */
482
    function getSequenceDefinition(&$db, $sequence)
483
    {
484
        // new in MDB
485
    }
486
}
487
 
488
}
489
?>