| [ 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/sqlite/lmbSqliteColumnInfo.class.php'); 11 12 /** 13 * class lmbSqliteTableInfo. 14 * 15 * @package dbal 16 * @version $Id$ 17 */ 18 class lmbSqliteTableInfo 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 $sql = "PRAGMA table_info('" . $this->name . "')"; 43 $queryId = $connection->execute($sql); 44 45 while($row = sqlite_fetch_array($queryId, SQLITE_ASSOC)) 46 { 47 $name = $row['name']; 48 49 $fulltype = $row['type']; 50 $size = null; 51 $scale = null; 52 if(preg_match('/^([^\(]+)\(\s*(\d+)\s*,\s*(\d+)\s*\)$/', $fulltype, $matches)) 53 { 54 $type = $matches[1]; 55 $size = $matches[2]; 56 $scale = $matches[3]; // aka precision 57 } 58 elseif(preg_match('/^([^\(]+)\(\s*(\d+)\s*\)$/', $fulltype, $matches)) 59 { 60 $type = $matches[1]; 61 $size = $matches[2]; 62 } 63 else 64 $type = $fulltype; 65 66 // If column is primary key and of type INTEGER, it is auto increment 67 // See: http://sqlite.org/faq.html#q1 68 $is_auto_increment = ($row['pk'] == 1 && $fulltype == 'INTEGER'); 69 $not_null = $row['notnull']; 70 $is_nullable = !$not_null; 71 72 $default_val = $row['dflt_value']; 73 74 $this->columns[$name] = new lmbSqliteColumnInfo($this, $name, $type, $size, $scale, 75 $is_nullable, $default_val, $is_auto_increment); 76 77 if(($row['pk'] == 1) || (strtolower($type) == 'integer primary key')) 78 { 79 //primary key handling... 80 } 81 } 82 $this->isColumnsLoaded = true; 83 } 84 } 85 } 86 87 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Aug 29 04:49:26 2008 | Cross-referenced by PHPXref 0.7 |