[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Database column information. 19 * 20 * @package core_dml 21 * @copyright 2008 Petr Skoda (http://skodak.org) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Detailed database field information. 29 * 30 * It is based on the adodb library's ADOFieldObject object. 31 * 'column' does mean 'the field' here. 32 * 33 * @package core_dml 34 * @copyright 2008 Petr Skoda (http://skodak.org) 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class database_column_info { 38 /** 39 * Name of column - lowercase. 40 * @var string 41 */ 42 public $name; 43 44 /** 45 * Driver dependent native data type. 46 * Not standardised, its used to find meta_type. 47 * @var string 48 */ 49 public $type; 50 51 /** 52 * Max length: 53 * character type - number of characters 54 * blob - number of bytes 55 * integer - number of digits 56 * float - digits left from floating point 57 * boolean - 1 58 * @var int 59 */ 60 public $max_length; 61 62 /** 63 * Scale 64 * float - decimal points 65 * other - null 66 * @var int 67 */ 68 public $scale; 69 70 /** 71 * True if not null, false otherwise 72 * @var bool 73 */ 74 public $not_null; 75 76 /** 77 * True if column is primary key. 78 * (usually 'id'). 79 * @var bool 80 */ 81 public $primary_key; 82 83 /** 84 * True if filed autoincrementing 85 * (usually 'id' only) 86 * @var bool 87 */ 88 public $auto_increment; 89 90 /** 91 * True if binary 92 * @var bool 93 */ 94 public $binary; 95 96 /** 97 * True if integer unsigned, false if signed. 98 * Null for other types 99 * @var integer 100 * @deprecated since 2.3 101 */ 102 public $unsigned; 103 104 /** 105 * True if the default value is defined. 106 * @var bool 107 */ 108 public $has_default; 109 110 /** 111 * The default value (if defined). 112 * @var string 113 */ 114 public $default_value; 115 116 /** 117 * True if field values are unique, false if not. 118 * @var bool 119 */ 120 public $unique; 121 122 /** 123 * Standardised one character column type, uppercased and enumerated as follows: 124 * R - counter (integer primary key) 125 * I - integers 126 * N - numbers (floats) 127 * C - characters and strings 128 * X - texts 129 * B - binary blobs 130 * L - boolean (1 bit) 131 * T - timestamp - unsupported 132 * D - date - unsupported 133 * @var string 134 */ 135 public $meta_type; 136 137 /** 138 * Constructor 139 * @param mixed $data object or array with properties 140 */ 141 public function __construct($data) { 142 foreach ($data as $key=>$value) { 143 if (property_exists($this, $key)) { 144 $this->$key = $value; 145 } 146 } 147 148 switch ($this->meta_type) { 149 case 'R': // normalise counters (usually 'id') 150 $this->binary = false; 151 $this->has_default = false; 152 $this->default_value = null; 153 $this->unique = true; 154 break; 155 case 'C': 156 $this->auto_increment = false; 157 $this->binary = false; 158 break; 159 } 160 } 161 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |