[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * $Id: SqliteDDLBuilder.php 1310 2006-05-04 07:36:54Z fabien $ 5 * 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 7 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 8 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 9 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 10 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 11 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 12 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 13 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 14 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 16 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 * 18 * This software consists of voluntary contributions made by many individuals 19 * and is licensed under the LGPL. For more information please see 20 * <http://propel.phpdb.org>. 21 */ 22 23 require_once 'propel/engine/builder/sql/DDLBuilder.php'; 24 25 /** 26 * The SQL DDL-building class for SQLite. 27 * 28 * 29 * @author Hans Lellelid <hans@xmpl.org> 30 * @package propel.engine.builder.sql.pgsql 31 */ 32 class SqliteDDLBuilder extends DDLBuilder { 33 34 /** 35 * 36 * @see parent::addDropStatement() 37 */ 38 protected function addDropStatements(&$script) 39 { 40 $table = $this->getTable(); 41 $platform = $this->getPlatform(); 42 43 $script .= " 44 DROP TABLE ".$this->quoteIdentifier($table->getName())."; 45 "; 46 } 47 48 /** 49 * 50 * @see parent::addColumns() 51 */ 52 protected function addTable(&$script) 53 { 54 $table = $this->getTable(); 55 $platform = $this->getPlatform(); 56 57 $script .= " 58 ----------------------------------------------------------------------------- 59 -- ".$table->getName()." 60 ----------------------------------------------------------------------------- 61 "; 62 63 $this->addDropStatements($script); 64 65 $script .= " 66 67 CREATE TABLE ".$this->quoteIdentifier($table->getName())." 68 ( 69 "; 70 71 $lines = array(); 72 73 foreach ($table->getColumns() as $col) { 74 $lines[] = $this->getColumnDDL($col); 75 } 76 77 foreach ($table->getUnices() as $unique ) { 78 $lines[] = "UNIQUE (".$this->getColumnList($unique->getColumns()).")"; 79 } 80 81 $sep = ", 82 "; 83 $script .= implode($sep, $lines); 84 $script .= " 85 ); 86 "; 87 } 88 89 /** 90 * Adds CREATE INDEX statements for this table. 91 * @see parent::addIndices() 92 */ 93 protected function addIndices(&$script) 94 { 95 $table = $this->getTable(); 96 $platform = $this->getPlatform(); 97 98 foreach ($table->getIndices() as $index) { 99 $script .= " 100 CREATE "; 101 if($index->getIsUnique()) { 102 $script .= "UNIQUE"; 103 } 104 $script .= "INDEX ".$this->quoteIdentifier($index->getName())." ON ".$this->quoteIdentifier($table->getName())." (".$this->getColumnList($index->getColumns())."); 105 "; 106 } 107 } 108 109 /** 110 * 111 * @see parent::addForeignKeys() 112 */ 113 protected function addForeignKeys(&$script) 114 { 115 $table = $this->getTable(); 116 $platform = $this->getPlatform(); 117 118 foreach ($table->getForeignKeys() as $fk) { 119 $script .= " 120 -- SQLite does not support foreign keys; this is just for reference 121 -- FOREIGN KEY (".$this->getColumnList($fk->getLocalColumns()).") REFERENCES ".$fk->getForeignTableName()." (".$this->getColumnList($fk->getForeignColumns()).") 122 "; 123 } 124 } 125 126 }
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 |