| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/dbal/src/drivers/lmbDbTableInfo.class.php'); 10 lmb_require('limb/dbal/src/drivers/mysql/lmbMysqlColumnInfo.class.php'); 11 12 /** 13 * class lmbMysqlTableInfo. 14 * 15 * @package dbal 16 * @version $Id: lmbMysqlTableInfo.class.php 5945 2007-06-06 08:31:43Z pachanga $ 17 */ 18 class lmbMysqlTableInfo extends lmbDbTableInfo 19 { 20 protected $isExisting = false; 21 protected $isColumnsLoaded = false; 22 protected $database; 23 24 function __construct($database, $name, $isExisting = false) 25 { 26 parent::__construct($name); 27 $this->database = $database; 28 $this->isExisting = $isExisting; 29 } 30 31 function getDatabase() 32 { 33 return $this->database; 34 } 35 36 //Based on code from Creole 37 function loadColumns() 38 { 39 if($this->isExisting && !$this->isColumnsLoaded) 40 { 41 $connection = $this->database->getConnection(); 42 $queryId = $connection->execute("SHOW COLUMNS FROM `" . $this->name . "`"); 43 44 while($row = mysql_fetch_assoc($queryId)) 45 { 46 $name = $row['Field']; 47 $isNullable =($row['Null'] == 'YES'); 48 $isAutoIncrement =(strpos($row['Extra'], 'auto_increment') !== false); 49 $size = null; 50 $precision = null; 51 52 if(preg_match('/^(\w+)[\(]?([\d,]*)[\)]?( |$)/', $row['Type'], $matches)) 53 { 54 // colname[1] size/precision[2] 55 $nativeType = $matches[1]; 56 if($matches[2]) 57 { 58 if(($cpos = strpos($matches[2], ',')) !== false) 59 { 60 $size = (int) substr($matches[2], 0, $cpos); 61 $precision = (int) substr($matches[2], $cpos + 1); 62 } 63 else 64 { 65 $size = (int) $matches[2]; 66 } 67 } 68 } 69 elseif(preg_match('/^(\w+)\(/', $row['Type'], $matches)) 70 { 71 $nativeType = $matches[1]; 72 } 73 else 74 { 75 $nativeType = $row['Type']; 76 } 77 78 // BLOBs can't have any default values in MySQL 79 $default = preg_match('~blob|text~', $nativeType) ? null : $row['Default']; 80 81 $this->columns[$name] = new lmbMysqlColumnInfo($this, 82 $name, $nativeType, $size, $precision, $isNullable, $default, $isAutoIncrement); 83 } 84 $this->isColumnsLoaded = true; 85 } 86 } 87 } 88 89 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Oct 7 05:02:03 2008 | Cross-referenced by PHPXref 0.7 |