[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * $Id: MySQLTypes.php,v 1.8 2005/02/10 09:22:40 pachanga Exp $ 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://creole.phpdb.org>. 21 */ 22 23 require_once 'creole/CreoleTypes.php'; 24 25 /** 26 * MySQL types / type map. 27 * 28 * @author Hans Lellelid <hans@xmpl.org> 29 * @version $Revision: 1.8 $ 30 * @package creole.drivers.mysql 31 */ 32 class MySQLTypes extends CreoleTypes { 33 34 /** Map MySQL native types to Creole (JDBC) types. */ 35 private static $typeMap = array( 36 'tinyint' => CreoleTypes::TINYINT, 37 'smallint' => CreoleTypes::SMALLINT, 38 'mediumint' => CreoleTypes::SMALLINT, 39 'int' => CreoleTypes::INTEGER, 40 'integer' => CreoleTypes::INTEGER, 41 'bigint' => CreoleTypes::BIGINT, 42 'int24' => CreoleTypes::BIGINT, 43 'real' => CreoleTypes::REAL, 44 'float' => CreoleTypes::FLOAT, 45 'decimal' => CreoleTypes::DECIMAL, 46 'numeric' => CreoleTypes::NUMERIC, 47 'double' => CreoleTypes::DOUBLE, 48 'char' => CreoleTypes::CHAR, 49 'varchar' => CreoleTypes::VARCHAR, 50 'date' => CreoleTypes::DATE, 51 'time' => CreoleTypes::TIME, 52 'year' => CreoleTypes::YEAR, 53 'datetime' => CreoleTypes::TIMESTAMP, 54 'timestamp' => CreoleTypes::TIMESTAMP, 55 'tinyblob' => CreoleTypes::BINARY, 56 'blob' => CreoleTypes::VARBINARY, 57 'mediumblob' => CreoleTypes::VARBINARY, 58 'longblob' => CreoleTypes::VARBINARY, 59 'longtext' => CreoleTypes::LONGVARCHAR, 60 'tinytext' => CreoleTypes::VARCHAR, 61 'mediumtext' => CreoleTypes::LONGVARCHAR, 62 'text' => CreoleTypes::LONGVARCHAR, 63 'enum' => CreoleTypes::CHAR, 64 'set' => CreoleTypes::CHAR, 65 ); 66 67 /** Reverse mapping, created on demand. */ 68 private static $reverseMap = null; 69 70 /** 71 * This method returns the generic Creole (JDBC-like) type 72 * when given the native db type. 73 * @param string $nativeType DB native type (e.g. 'TEXT', 'byetea', etc.). 74 * @return int Creole native type (e.g. CreoleTypes::LONGVARCHAR, CreoleTypes::BINARY, etc.). 75 */ 76 public static function getType($nativeType) 77 { 78 $t = strtolower($nativeType); 79 if (isset(self::$typeMap[$t])) { 80 return self::$typeMap[$t]; 81 } else { 82 return CreoleTypes::OTHER; 83 } 84 } 85 86 /** 87 * This method will return a native type that corresponds to the specified 88 * Creole (JDBC-like) type. 89 * If there is more than one matching native type, then the LAST defined 90 * native type will be returned. 91 * @param int $creoleType 92 * @return string Native type string. 93 */ 94 public static function getNativeType($creoleType) 95 { 96 if (self::$reverseMap === null) { 97 self::$reverseMap = array_flip(self::$typeMap); 98 } 99 return @self::$reverseMap[$creoleType]; 100 } 101 102 }
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 |