Import.php 5.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<?php
/*
 *  $Id$
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information, see
 * <http://www.phpdoctrine.com>.
 */
21
Doctrine::autoload('Doctrine_Connection_Module');
22 23 24 25 26
/**
 * class Doctrine_Import
 * Main responsible of performing import operation. Delegates database schema
 * reading to a reader object and passes the result to a builder object which
 * builds a Doctrine data model.
27
 *
28 29 30 31 32 33 34
 * @package     Doctrine
 * @category    Object Relational Mapping
 * @link        www.phpdoctrine.com
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @since       1.0
 * @version     $Revision$
 * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
35
 * @author      Jukka Hassinen <Jukka.Hassinen@BrainAlliance.com>
36
 */
37 38 39
class Doctrine_Import extends Doctrine_Connection_Module 
{
    protected $sql = array();
40 41 42 43 44
    /**
     * lists all databases
     *
     * @return array
     */
45 46 47 48 49 50 51
    public function listDatabases() 
    {
        if( ! isset($this->sql['listDatabases'])) {
            throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
        }

        return $this->conn->fetchColumn($this->sql['listDatabases']);
52 53 54 55 56 57
    }
    /**
     * lists all availible database functions
     *
     * @return array
     */
58 59 60 61 62 63 64
    public function listFunctions() 
    {
        if( ! isset($this->sql['listFunctions'])) {
            throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
        }

        return $this->conn->fetchColumn($this->sql['listFunctions']);
65 66 67 68 69 70 71
    }
    /**
     * lists all database triggers
     *
     * @param string|null $database
     * @return array
     */
72 73
    public function listTriggers($database = null) 
    {
74 75 76 77 78 79 80 81
        throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
    }
    /**
     * lists all database sequences
     *
     * @param string|null $database
     * @return array
     */
82 83 84 85 86 87 88
    public function listSequences($database = null) 
    {
        if( ! isset($this->sql['listSequences'])) {
            throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
        }

        return $this->conn->fetchColumn($this->sql['listSequences']);
89 90 91 92 93 94 95
    }
    /**
     * lists table constraints
     *
     * @param string $table     database table name
     * @return array
     */
96 97
    public function listTableConstraints($table) 
    {
98 99
        throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
    }
100
    /**
101 102 103 104
     * lists table constraints
     *
     * @param string $table     database table name
     * @return array
105
     */
106 107
    public function listTableColumns($table) 
    {
108 109
        throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
    }
110
    /**
111 112 113 114
     * lists table constraints
     *
     * @param string $table     database table name
     * @return array
115
     */
116 117
    public function listTableIndexes($table) 
    {
118 119 120 121 122 123 124 125
        throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
    }
    /**
     * lists tables
     *
     * @param string|null $database
     * @return array
     */
126 127
    public function listTables($database = null) 
    {
128 129 130 131 132 133 134 135
        throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
    }
    /**
     * lists table triggers
     *
     * @param string $table     database table name
     * @return array
     */
136 137
    public function listTableTriggers($table) 
    {
138 139
        throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
    }
140
    /**
141
     * lists table views
142
     *
143 144
     * @param string $table     database table name
     * @return array
145
     */
146 147
    public function listTableViews($table) 
    {
148
        throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
149
    }
150
    /**
151
     * lists database users
152
     *
153
     * @return array
154
     */
155 156 157 158 159 160 161
    public function listUsers() 
    {
        if( ! isset($this->sql['listUsers'])) {
            throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
        }

        return $this->conn->fetchColumn($this->sql['listUsers']);
162
    }
163
    /**
164
     * lists database views
165
     *
166 167
     * @param string|null $database
     * @return array
168
     */
169 170 171 172 173 174 175
    public function listViews($database = null) 
    {
        if( ! isset($this->sql['listViews'])) {
            throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
        }

        return $this->conn->fetchColumn($this->sql['listViews']);
176 177
    }
}