MDB2
[ class tree: MDB2 ] [ index: MDB2 ] [ all elements ]

Source for file Driver_Manager_skeleton.php

Documentation is available at Driver_Manager_skeleton.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP versions 4 and 5                                                 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox,                 |
  6. // | Stig. S. Bakken, Lukas Smith                                         |
  7. // | All rights reserved.                                                 |
  8. // +----------------------------------------------------------------------+
  9. // | MDB2 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: Driver_Manager_skeleton.php,v 1.6 2005/10/06 08:50:23 lsmith Exp $
  46. //
  47.  
  48. // This is just a skeleton MDB2 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 MDB2" 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 MDB2.
  56. // Looking in the relevant MDB2 Wrapper should give you some pointers, some
  57. // other difference you will only discover by looking at one of the existing
  58. // MDB2 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. require_once 'MDB2/Driver/Manager/Common.php';
  64.  
  65. /**
  66.  * MDB2 Xxx driver for the management modules
  67.  *
  68.  * @package MDB2
  69.  * @category Database
  70.  * @author  YOUR NAME <YOUR EMAIL>
  71.  */
  72. {
  73.     // }}}
  74.     // {{{ createDatabase()
  75.  
  76.     /**
  77.      * create a new database
  78.      *
  79.      * @param string $name name of the database that should be created
  80.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  81.      * @access public
  82.      */
  83.     function createDatabase($name)
  84.     {
  85.         // take this from the corresponding Metabase driver: CreateDatabase()
  86.     }
  87.  
  88.     // }}}
  89.     // {{{ dropDatabase()
  90.  
  91.     /**
  92.      * drop an existing database
  93.      *
  94.      * @param string $name name of the database that should be dropped
  95.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  96.      * @access public
  97.      */
  98.     function dropDatabase($name)
  99.     {
  100.         // take this from the corresponding Metabase driver: DropDatabase()
  101.     }
  102.  
  103.     // }}}
  104.     // {{{ createTable()
  105.  
  106.     /**
  107.      * create a new table
  108.      *
  109.      * @param string $name     Name of the database that should be created
  110.      * @param array $fields Associative array that contains the definition of each field of the new table
  111.      *                         The indexes of the array entries are the names of the fields of the table an
  112.      *                         the array entry values are associative arrays like those that are meant to be
  113.      *                          passed with the field definitions to get[Type]Declaration() functions.
  114.      *
  115.      *                         Example
  116.      *                         array(
  117.      *
  118.      *                             'id' => array(
  119.      *                                 'type' => 'integer',
  120.      *                                 'unsigned' => 1
  121.      *                                 'notnull' => 1
  122.      *                                 'default' => 0
  123.      *                             ),
  124.      *                             'name' => array(
  125.      *                                 'type' => 'text',
  126.      *                                 'length' => 12
  127.      *                             ),
  128.      *                             'password' => array(
  129.      *                                 'type' => 'text',
  130.      *                                 'length' => 12
  131.      *                             )
  132.      *                         );
  133.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  134.      * @access public
  135.      */
  136.     function createTable($name$fields)
  137.     {
  138.         // take this from the corresponding Metabase driver: CreateTable()
  139.     }
  140.  
  141.  
  142.     // }}}
  143.     // {{{ alterTable()
  144.  
  145.     /**
  146.      * alter an existing table
  147.      *
  148.      * @param string $name         name of the table that is intended to be changed.
  149.      * @param array $changes     associative array that contains the details of each type
  150.      *                              of change that is intended to be performed. The types of
  151.      *                              changes that are currently supported are defined as follows:
  152.      *
  153.      *                              name
  154.      *
  155.      *                                 New name for the table.
  156.      *
  157.      *                             add
  158.      *
  159.      *                                 Associative array with the names of fields to be added as
  160.      *                                  indexes of the array. The value of each entry of the array
  161.      *                                  should be set to another associative array with the properties
  162.      *                                  of the fields to be added. The properties of the fields should
  163.      *                                  be the same as defined by the Metabase parser.
  164.      *
  165.      *
  166.      *                             remove
  167.      *
  168.      *                                 Associative array with the names of fields to be removed as indexes
  169.      *                                  of the array. Currently the values assigned to each entry are ignored.
  170.      *                                  An empty array should be used for future compatibility.
  171.      *
  172.      *                             rename
  173.      *
  174.      *                                 Associative array with the names of fields to be renamed as indexes
  175.      *                                  of the array. The value of each entry of the array should be set to
  176.      *                                  another associative array with the entry named name with the new
  177.      *                                  field name and the entry named Declaration that is expected to contain
  178.      *                                  the portion of the field declaration already in DBMS specific SQL code
  179.      *                                  as it is used in the CREATE TABLE statement.
  180.      *
  181.      *                             change
  182.      *
  183.      *                                 Associative array with the names of the fields to be changed as indexes
  184.      *                                  of the array. Keep in mind that if it is intended to change either the
  185.      *                                  name of a field and any other properties, the change array entries
  186.      *                                  should have the new names of the fields as array indexes.
  187.      *
  188.      *                                 The value of each entry of the array should be set to another associative
  189.      *                                  array with the properties of the fields to that are meant to be changed as
  190.      *                                  array entries. These entries should be assigned to the new values of the
  191.      *                                  respective properties. The properties of the fields should be the same
  192.      *                                  as defined by the Metabase parser.
  193.      *
  194.      *                             Example
  195.      *                                 array(
  196.      *                                     'name' => 'userlist',
  197.      *                                     'add' => array(
  198.      *                                         'quota' => array(
  199.      *                                             'type' => 'integer',
  200.      *                                             'unsigned' => 1
  201.      *                                         )
  202.      *                                     ),
  203.      *                                     'remove' => array(
  204.      *                                         'file_limit' => array(),
  205.      *                                         'time_limit' => array()
  206.      *                                         ),
  207.      *                                     'change' => array(
  208.      *                                         'gender' => array(
  209.      *                                             'default' => 'M',
  210.      *                                         )
  211.      *                                     ),
  212.      *                                     'rename' => array(
  213.      *                                         'sex' => array(
  214.      *                                             'name' => 'gender',
  215.      *                                         )
  216.      *                                     )
  217.      *                                 )
  218.      *
  219.      * @param boolean $check     indicates whether the function should just check if the DBMS driver
  220.      *                              can perform the requested table alterations if the value is true or
  221.      *                              actually perform them otherwise.
  222.      * @access public
  223.      *
  224.       * @return mixed MDB2_OK on success, a MDB2 error on failure
  225.      */
  226.     function alterTable($name$changes$check)
  227.     {
  228.         // take this from the corresponding Metabase driver: AlterTable()
  229.     }
  230.  
  231.     // }}}
  232.     // {{{ listDatabases()
  233.  
  234.     /**
  235.      * list all databases
  236.      *
  237.      * @return mixed data array on success, a MDB2 error on failure
  238.      * @access public
  239.      */
  240.     function listDatabases()
  241.     {
  242.         // new in MDB2
  243.     }
  244.  
  245.     // }}}
  246.     // {{{ listUsers()
  247.  
  248.     /**
  249.      * list all users
  250.      *
  251.      * @return mixed data array on success, a MDB2 error on failure
  252.      * @access public
  253.      */
  254.     function listUsers()
  255.     {
  256.         // new in MDB2
  257.     }
  258.  
  259.     // }}}
  260.     // {{{ listTables()
  261.  
  262.     /**
  263.      * list all tables in the current database
  264.      *
  265.      * @return mixed data array on success, a MDB2 error on failure
  266.      * @access public
  267.      */
  268.     function listTables()
  269.     {
  270.         // new in MDB2
  271.     }
  272.  
  273.     // }}}
  274.     // {{{ listTableFields()
  275.  
  276.     /**
  277.      * list all fields in a tables in the current database
  278.      *
  279.      * @param string $table name of table that should be used in method
  280.      * @return mixed data array on success, a MDB2 error on failure
  281.      * @access public
  282.      */
  283.     function listTableFields($table)
  284.     {
  285.         // new in MDB2
  286.     }
  287.  
  288.     // }}}
  289.     // {{{ createIndex()
  290.  
  291.     /**
  292.      * get the stucture of a field into an array
  293.      *
  294.      * @param string    $table         name of the table on which the index is to be created
  295.      * @param string    $name         name of the index to be created
  296.      * @param array     $definition        associative array that defines properties of the index to be created.
  297.      *                                  Currently, only one property named FIELDS is supported. This property
  298.      *                                  is also an associative with the names of the index fields as array
  299.      *                                  indexes. Each entry of this array is set to another type of associative
  300.      *                                  array that specifies properties of the index that are specific to
  301.      *                                  each field.
  302.      *
  303.      *                                 Currently, only the sorting property is supported. It should be used
  304.      *                                  to define the sorting direction of the index. It may be set to either
  305.      *                                  ascending or descending.
  306.      *
  307.      *                                 Not all DBMS support index sorting direction configuration. The DBMS
  308.      *                                  drivers of those that do not support it ignore this property. Use the
  309.      *                                  function support() to determine whether the DBMS driver can manage indexes.
  310.  
  311.      *                                  Example
  312.      *                                     array(
  313.      *                                         'FIELDS' => array(
  314.      *                                             'user_name' => array(
  315.      *                                                 'sorting' => 'ascending'
  316.      *                                             ),
  317.      *                                             'last_login' => array()
  318.      *                                         )
  319.      *                                     )
  320.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  321.      * @access public
  322.      */
  323.     function createIndex($table$name$definition)
  324.     {
  325.         // take this from the corresponding Metabase driver: CreateIndex()
  326.     }
  327.  
  328.     // }}}
  329.     // {{{ dropIndex()
  330.  
  331.     /**
  332.      * drop existing index
  333.      *
  334.      * @param string    $table         name of table that should be used in method
  335.      * @param string    $name         name of the index to be dropped
  336.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  337.      * @access public
  338.      */
  339.     function dropIndex($table$name)
  340.     {
  341.         // take this from the corresponding Metabase driver: DropIndex()
  342.     }
  343.  
  344.     // }}}
  345.     // {{{ listTableIndexes()
  346.  
  347.     /**
  348.      * list all indexes in a table
  349.      *
  350.      * @param string    $table      name of table that should be used in method
  351.      * @return mixed data array on success, a MDB2 error on failure
  352.      * @access public
  353.      */
  354.     function listTableIndexes($table)
  355.     {
  356.         // new in MDB2
  357.     }
  358.  
  359.  
  360.     // }}}
  361.     // {{{ createSequence()
  362.  
  363.     /**
  364.      * create sequence
  365.      *
  366.      * @param string    $seq_name     name of the sequence to be created
  367.      * @param string    $start         start value of the sequence; default is 1
  368.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  369.      * @access public
  370.      */
  371.     function createSequence($seq_name$start)
  372.     {
  373.         // take this from the corresponding Metabase driver: CreateSequence()
  374.     }
  375.  
  376.     // }}}
  377.     // {{{ dropSequence()
  378.  
  379.     /**
  380.      * drop existing sequence
  381.      *
  382.      * @param string    $seq_name     name of the sequence to be dropped
  383.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  384.      * @access public
  385.      */
  386.     function dropSequence($seq_name)
  387.     {
  388.         // take this from the corresponding Metabase driver: DropSequence()
  389.     }
  390.  
  391.     // }}}
  392.     // {{{ listSequences()
  393.  
  394.     /**
  395.      * list all sequences in the current database
  396.      *
  397.      * @return mixed data array on success, a MDB2 error on failure
  398.      * @access public
  399.      */
  400.     function listSequences()
  401.     {
  402.         // new in MDB2
  403.     }
  404. }
  405. ?>

Documentation generated on Mon, 11 Mar 2019 14:36:21 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.