| [ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: PgSQLDatabaseInfo.php,v 1.11 2006/01/17 19:44:40 hlellelid Exp $ 4 * 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 * 17 * This software consists of voluntary contributions made by many individuals 18 * and is licensed under the LGPL. For more information please see 19 * <http://creole.phpdb.org>. 20 */ 21 22 require_once 'creole/metadata/DatabaseInfo.php'; 23 24 /** 25 * MySQL implementation of DatabaseInfo. 26 * 27 * @author Hans Lellelid <hans@xmpl.org> 28 * @version $Revision: 1.11 $ 29 * @package creole.drivers.pgsql.metadata 30 */ 31 class PgSQLDatabaseInfo extends DatabaseInfo { 32 33 /** 34 * @throws SQLException 35 * @return void 36 */ 37 protected function initTables() 38 { 39 include_once 'creole/drivers/pgsql/metadata/PgSQLTableInfo.php'; 40 41 // Get Database Version 42 // TODO: www.php.net/pg_version 43 $result = pg_query ($this->conn->getResource(), "SELECT version() as ver"); 44 45 if (!$result) 46 { 47 throw new SQLException ("Failed to select database version"); 48 } // if (!$result) 49 $row = pg_fetch_assoc ($result, 0); 50 $arrVersion = sscanf ($row['ver'], '%*s %d.%d'); 51 $version = sprintf ("%d.%d", $arrVersion[0], $arrVersion[1]); 52 // Clean up 53 $arrVersion = null; 54 $row = null; 55 pg_free_result ($result); 56 $result = null; 57 58 $result = pg_query($this->conn->getResource(), "SELECT oid, relname FROM pg_class 59 WHERE relkind = 'r' AND relnamespace = (SELECT oid 60 FROM pg_namespace 61 WHERE 62 nspname NOT IN ('information_schema','pg_catalog') 63 AND nspname NOT LIKE 'pg_temp%' 64 AND nspname NOT LIKE 'pg_toast%' 65 LIMIT 1) 66 ORDER BY relname"); 67 68 if (!$result) { 69 throw new SQLException("Could not list tables", pg_last_error($this->dblink)); 70 } 71 72 while ($row = pg_fetch_assoc($result)) { 73 $this->tables[strtoupper($row['relname'])] = new PgSQLTableInfo($this, $row['relname'], $version, $row['oid']); 74 } 75 76 $this->tablesLoaded = true; 77 } 78 79 /** 80 * PgSQL sequences. 81 * 82 * @return void 83 * @throws SQLException 84 */ 85 protected function initSequences() 86 { 87 88 $this->sequences = array(); 89 90 $result = pg_query($this->conn->getResource(), "SELECT oid, relname FROM pg_class 91 WHERE relkind = 'S' AND relnamespace = (SELECT oid 92 FROM pg_namespace 93 WHERE 94 nspname NOT IN ('information_schema','pg_catalog') 95 AND nspname NOT LIKE 'pg_temp%' 96 AND nspname NOT LIKE 'pg_toast%' 97 LIMIT 1) 98 ORDER BY relname"); 99 100 if (!$result) { 101 throw new SQLException("Could not list sequences", pg_last_error($this->dblink)); 102 } 103 104 while ($row = pg_fetch_assoc($result)) { 105 // FIXME -- decide what info we need for sequences & then create a SequenceInfo object (if needed) 106 $obj = new stdClass; 107 $obj->name = $row['relname']; 108 $obj->oid = $row['oid']; 109 $this->sequences[strtoupper($row['relname'])] = $obj; 110 } 111 112 } 113 114 } 115
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |