Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/xmldb/xmldb_field.php
Go to the documentation of this file.
00001 <?php
00002 
00004 //                                                                       //
00005 // NOTICE OF COPYRIGHT                                                   //
00006 //                                                                       //
00007 // Moodle - Modular Object-Oriented Dynamic Learning Environment         //
00008 //          http://moodle.com                                            //
00009 //                                                                       //
00010 // Copyright (C) 1999 onwards Martin Dougiamas     http://dougiamas.com  //
00011 //           (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com  //
00012 //                                                                       //
00013 // This program is free software; you can redistribute it and/or modify  //
00014 // it under the terms of the GNU General Public License as published by  //
00015 // the Free Software Foundation; either version 2 of the License, or     //
00016 // (at your option) any later version.                                   //
00017 //                                                                       //
00018 // This program is distributed in the hope that it will be useful,       //
00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of        //
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
00021 // GNU General Public License for more details:                          //
00022 //                                                                       //
00023 //          http://www.gnu.org/copyleft/gpl.html                         //
00024 //                                                                       //
00026 
00028 
00029 class xmldb_field extends xmldb_object {
00030 
00031     var $type;
00032     var $length;
00033     var $unsigned;
00034     var $notnull;
00035     var $default;
00036     var $sequence;
00037     var $decimals;
00038 
00048     const CHAR_MAX_LENGTH = 1333;
00049 
00053     function __construct($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
00054         $this->type = NULL;
00055         $this->length = NULL;
00056         $this->unsigned = true;
00057         $this->notnull = false;
00058         $this->default = NULL;
00059         $this->sequence = false;
00060         $this->decimals = NULL;
00061         parent::__construct($name);
00062         $this->set_attributes($type, $precision, $unsigned, $notnull, $sequence, $default, $previous);
00063     }
00064 
00067 
00068     function setAttributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
00069 
00070         debugging('XMLDBField->setAttributes() has been deprecated in Moodle 2.0. Will be out in Moodle 2.1. Please use xmldb_field->set_attributes() instead.', DEBUG_DEVELOPER);
00071         if ($enum) {
00072             debugging('Also, ENUMs support has been dropped in Moodle 2.0. Your fields specs are incorrect because you are trying to introduce one new ENUM. Created DB estructures will ignore that.');
00073         }
00074 
00075         return $this->set_attributes($type, $precision, $unsigned, $notnull, $sequence, $default, $previous);
00076     }
00078 
00089     function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
00090         $this->type = $type;
00093         $precisionarr = explode(',', $precision);
00094         if (isset($precisionarr[0])) {
00095             $this->length = trim($precisionarr[0]);
00096         }
00097         if (isset($precisionarr[1])) {
00098             $this->decimals = trim($precisionarr[1]);
00099         }
00100         $this->precision = $type;
00101         $this->unsigned = !empty($unsigned) ? true : false;
00102         $this->notnull = !empty($notnull) ? true : false;
00103         $this->sequence = !empty($sequence) ? true : false;
00104         $this->setDefault($default);
00105 
00106         $this->previous = $previous;
00107     }
00108 
00112     function getType() {
00113         return $this->type;
00114     }
00115 
00119     function getLength() {
00120         return $this->length;
00121     }
00122 
00126     function getDecimals() {
00127         return $this->decimals;
00128     }
00129 
00133     function getNotNull() {
00134         return $this->notnull;
00135     }
00136 
00140     function getUnsigned() {
00141         return $this->unsigned;
00142     }
00143 
00147     function getSequence() {
00148         return $this->sequence;
00149     }
00150 
00154     function getDefault() {
00155         return $this->default;
00156     }
00157 
00161     function setType($type) {
00162         $this->type = $type;
00163     }
00164 
00168     function setLength($length) {
00169         $this->length = $length;
00170     }
00171 
00175     function setDecimals($decimals) {
00176         $this->decimals = $decimals;
00177     }
00178 
00182     function setUnsigned($unsigned=true) {
00183         $this->unsigned = $unsigned;
00184     }
00185 
00189     function setNotNull($notnull=true) {
00190         $this->notnull = $notnull;
00191     }
00192 
00196     function setSequence($sequence=true) {
00197         $this->sequence = $sequence;
00198     }
00199 
00203     function setDefault($default) {
00206         if ($this->type == XMLDB_TYPE_CHAR && $this->notnull && $default === '') {
00207             $this->errormsg = 'XMLDB has detected one CHAR NOT NULL column (' . $this->name . ") with '' (empty string) as DEFAULT value. This type of columns must have one meaningful DEFAULT declared or none (NULL). XMLDB have fixed it automatically changing it to none (NULL). The process will continue ok and proper defaults will be created accordingly with each DB requirements. Please fix it in source (XML and/or upgrade script) to avoid this message to be displayed.";
00208             $this->debug($this->errormsg);
00209             $default = null;
00210         }
00212         if (($this->type == XMLDB_TYPE_TEXT || $this->type == XMLDB_TYPE_BINARY) && $default !== null) {
00213             $this->errormsg = 'XMLDB has detected one TEXT/BINARY column (' . $this->name . ") with some DEFAULT defined. This type of columns cannot have any default value. Please fix it in source (XML and/or upgrade script) to avoid this message to be displayed.";
00214             $this->debug($this->errormsg);
00215             $default = null;
00216         }
00217         $this->default = $default;
00218     }
00219 
00223     function arr2xmldb_field($xmlarr) {
00224 
00225         $result = true;
00226 
00231 
00234         if (isset($xmlarr['@']['NAME'])) {
00235             $this->name = trim($xmlarr['@']['NAME']);
00236         } else {
00237             $this->errormsg = 'Missing NAME attribute';
00238             $this->debug($this->errormsg);
00239             $result = false;
00240         }
00241 
00242         if (isset($xmlarr['@']['TYPE'])) {
00244             $type = $this->getXMLDBFieldType(trim($xmlarr['@']['TYPE']));
00245             if ($type) {
00246                 $this->type = $type;
00247             } else {
00248                 $this->errormsg = 'Invalid TYPE attribute';
00249                 $this->debug($this->errormsg);
00250                 $result = false;
00251             }
00252         } else {
00253             $this->errormsg = 'Missing TYPE attribute';
00254             $this->debug($this->errormsg);
00255             $result = false;
00256         }
00257 
00258         if (isset($xmlarr['@']['LENGTH'])) {
00259             $length = trim($xmlarr['@']['LENGTH']);
00261             if ($this->type == XMLDB_TYPE_INTEGER ||
00262                 $this->type == XMLDB_TYPE_NUMBER ||
00263                 $this->type == XMLDB_TYPE_CHAR) {
00264                 if (!(is_numeric($length)&&(intval($length)==floatval($length)))) {
00265                     $this->errormsg = 'Incorrect LENGTH attribute for int, number or char fields';
00266                     $this->debug($this->errormsg);
00267                     $result = false;
00268                 } else if (!$length) {
00269                     $this->errormsg = 'Zero LENGTH attribute';
00270                     $this->debug($this->errormsg);
00271                     $result = false;
00272                 }
00273             }
00275             if ($this->type == XMLDB_TYPE_TEXT ||
00276                 $this->type == XMLDB_TYPE_BINARY) {
00277                 if (!$length) {
00278                     $length == 'big';
00279                 }
00280                 if ($length != 'big' &&
00281                     $length != 'medium' &&
00282                     $length != 'small') {
00283                     $this->errormsg = 'Incorrect LENGTH attribute for text and binary fields (only big, medium and small allowed)';
00284                     $this->debug($this->errormsg);
00285                     $result = false;
00286                 }
00287             }
00289             $this->length = $length;
00290         }
00291 
00292         if (isset($xmlarr['@']['UNSIGNED'])) {
00293             $unsigned = strtolower(trim($xmlarr['@']['UNSIGNED']));
00294             if ($unsigned == 'true') {
00295                 $this->unsigned = true;
00296             } else if ($unsigned == 'false') {
00297                 $this->unsigned = false;
00298             } else {
00299                 $this->errormsg = 'Incorrect UNSIGNED attribute (true/false allowed)';
00300                 $this->debug($this->errormsg);
00301                 $result = false;
00302             }
00303         }
00304 
00305         if (isset($xmlarr['@']['NOTNULL'])) {
00306             $notnull = strtolower(trim($xmlarr['@']['NOTNULL']));
00307             if ($notnull == 'true') {
00308                 $this->notnull = true;
00309             } else if ($notnull == 'false') {
00310                 $this->notnull = false;
00311             } else {
00312                 $this->errormsg = 'Incorrect NOTNULL attribute (true/false allowed)';
00313                 $this->debug($this->errormsg);
00314                 $result = false;
00315             }
00316         }
00317 
00318         if (isset($xmlarr['@']['SEQUENCE'])) {
00319             $sequence = strtolower(trim($xmlarr['@']['SEQUENCE']));
00320             if ($sequence == 'true') {
00321                 $this->sequence = true;
00322             } else if ($sequence == 'false') {
00323                 $this->sequence = false;
00324             } else {
00325                 $this->errormsg = 'Incorrect SEQUENCE attribute (true/false allowed)';
00326                 $this->debug($this->errormsg);
00327                 $result = false;
00328             }
00329         }
00330 
00331         if (isset($xmlarr['@']['DEFAULT'])) {
00332             $this->setDefault(trim($xmlarr['@']['DEFAULT']));
00333         }
00334 
00335         $decimals = NULL;
00336         if (isset($xmlarr['@']['DECIMALS'])) {
00337             $decimals = trim($xmlarr['@']['DECIMALS']);
00339             if ($this->type == XMLDB_TYPE_NUMBER ||
00340                 $this->type == XMLDB_TYPE_FLOAT) {
00341                 if (!(is_numeric($decimals)&&(intval($decimals)==floatval($decimals)))) {
00342                     $this->errormsg = 'Incorrect DECIMALS attribute for number field';
00343                     $this->debug($this->errormsg);
00344                     $result = false;
00345                 } else if ($this->length <= $decimals){
00346                     $this->errormsg = 'Incorrect DECIMALS attribute (bigget than length)';
00347                     $this->debug($this->errormsg);
00348                     $result = false;
00349                 }
00350             } else {
00351                 $this->errormsg = 'Incorrect DECIMALS attribute for non-number field';
00352                 $this->debug($this->errormsg);
00353                 $result = false;
00354             }
00355         } else {
00356             if ($this->type == XMLDB_TYPE_NUMBER) {
00357                 $decimals = 0;
00358             }
00359         }
00360      // Finally, set the decimals
00361         if ($this->type == XMLDB_TYPE_NUMBER ||
00362             $this->type == XMLDB_TYPE_FLOAT) {
00363             $this->decimals = $decimals;
00364         }
00365 
00366         if (isset($xmlarr['@']['COMMENT'])) {
00367             $this->comment = trim($xmlarr['@']['COMMENT']);
00368         }
00369 
00370         if (isset($xmlarr['@']['PREVIOUS'])) {
00371             $this->previous = trim($xmlarr['@']['PREVIOUS']);
00372         }
00373 
00374         if (isset($xmlarr['@']['NEXT'])) {
00375             $this->next = trim($xmlarr['@']['NEXT']);
00376         }
00377 
00380         if (isset($xmlarr['@']['ENUM']) && isset($xmlarr['@']['ENUMVALUES'])) {
00381             $this->hasenums = true;
00382             if ($xmlarr['@']['ENUM'] == 'true') {
00383                 $this->hasenumsenabled = true;
00384             }
00385         }
00386 
00388         if ($result) {
00389             $this->loaded = true;
00390         }
00391         $this->calculateHash();
00392         return $result;
00393     }
00394 
00399     function getXMLDBFieldType($type) {
00400 
00401         $result = XMLDB_TYPE_INCORRECT;
00402 
00403         switch (strtolower($type)) {
00404             case 'int':
00405                 $result = XMLDB_TYPE_INTEGER;
00406                 break;
00407             case 'number':
00408                 $result = XMLDB_TYPE_NUMBER;
00409                 break;
00410             case 'float':
00411                 $result = XMLDB_TYPE_FLOAT;
00412                 break;
00413             case 'char':
00414                 $result = XMLDB_TYPE_CHAR;
00415                 break;
00416             case 'text':
00417                 $result = XMLDB_TYPE_TEXT;
00418                 break;
00419             case 'binary':
00420                 $result = XMLDB_TYPE_BINARY;
00421                 break;
00422             case 'datetime':
00423                 $result = XMLDB_TYPE_DATETIME;
00424                 break;
00425         }
00427         return $result;
00428     }
00429 
00434     function getXMLDBTypeName($type) {
00435 
00436         $result = "";
00437 
00438         switch (strtolower($type)) {
00439             case XMLDB_TYPE_INTEGER:
00440                 $result = 'int';
00441                 break;
00442             case XMLDB_TYPE_NUMBER:
00443                 $result = 'number';
00444                 break;
00445             case XMLDB_TYPE_FLOAT:
00446                 $result = 'float';
00447                 break;
00448             case XMLDB_TYPE_CHAR:
00449                 $result = 'char';
00450                 break;
00451             case XMLDB_TYPE_TEXT:
00452                 $result = 'text';
00453                 break;
00454             case XMLDB_TYPE_BINARY:
00455                 $result = 'binary';
00456                 break;
00457             case XMLDB_TYPE_DATETIME:
00458                 $result = 'datetime';
00459                 break;
00460         }
00462         return $result;
00463     }
00464 
00468      function calculateHash($recursive = false) {
00469         if (!$this->loaded) {
00470             $this->hash = NULL;
00471         } else {
00472             $key = $this->name . $this->type . $this->length .
00473                    $this->unsigned . $this->notnull . $this->sequence .
00474                    $this->decimals . $this->comment;
00475             $this->hash = md5($key);
00476         }
00477     }
00478 
00482     function xmlOutput() {
00483         $o = '';
00484         $o.= '        <FIELD NAME="' . $this->name . '"';
00485         $o.= ' TYPE="' . $this->getXMLDBTypeName($this->type) . '"';
00486         if ($this->length) {
00487             $o.= ' LENGTH="' . $this->length . '"';
00488         }
00489         if ($this->notnull) {
00490             $notnull = 'true';
00491         } else {
00492             $notnull = 'false';
00493         }
00494         $o.= ' NOTNULL="' . $notnull . '"';
00495         if ($this->type == XMLDB_TYPE_INTEGER ||
00496             $this->type == XMLDB_TYPE_NUMBER ||
00497             $this->type == XMLDB_TYPE_FLOAT) {
00498             if ($this->unsigned) {
00499                 $unsigned = 'true';
00500             } else {
00501                 $unsigned = 'false';
00502             }
00503             $o.= ' UNSIGNED="' . $unsigned . '"';
00504         }
00505         if (!$this->sequence && $this->default !== NULL) {
00506             $o.= ' DEFAULT="' . $this->default . '"';
00507         }
00508         if ($this->sequence) {
00509             $sequence = 'true';
00510         } else {
00511             $sequence = 'false';
00512         }
00513         $o.= ' SEQUENCE="' . $sequence . '"';
00514         if ($this->decimals !== NULL) {
00515             $o.= ' DECIMALS="' . $this->decimals . '"';
00516         }
00517         if ($this->comment) {
00518             $o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"';
00519         }
00520         if ($this->previous) {
00521             $o.= ' PREVIOUS="' . $this->previous . '"';
00522         }
00523         if ($this->next) {
00524             $o.= ' NEXT="' . $this->next . '"';
00525         }
00526         $o.= '/>' . "\n";
00527 
00528         return $o;
00529     }
00530 
00535     function setFromADOField($adofield) {
00536 
00538         switch (strtolower($adofield->type)) {
00539             case 'int':
00540             case 'tinyint':
00541             case 'smallint':
00542             case 'bigint':
00543             case 'integer':
00544                 $this->type = XMLDB_TYPE_INTEGER;
00545                 break;
00546             case 'number':
00547             case 'decimal':
00548             case 'dec':
00549             case 'numeric':
00550                 $this->type = XMLDB_TYPE_NUMBER;
00551                 break;
00552             case 'float':
00553             case 'double':
00554                 $this->type = XMLDB_TYPE_FLOAT;
00555                 break;
00556             case 'char':
00557             case 'varchar':
00558             case 'enum':
00559                 $this->type = XMLDB_TYPE_CHAR;
00560                 break;
00561             case 'text':
00562             case 'tinytext':
00563             case 'mediumtext':
00564             case 'longtext':
00565                 $this->type = XMLDB_TYPE_TEXT;
00566                 break;
00567             case 'blob':
00568             case 'tinyblob':
00569             case 'mediumblob':
00570             case 'longblob':
00571                 $this->type = XMLDB_TYPE_BINARY;
00572                 break;
00573             case 'datetime':
00574             case 'timestamp':
00575                 $this->type = XMLDB_TYPE_DATETIME;
00576                 break;
00577             default:
00578                 $this->type = XMLDB_TYPE_TEXT;
00579         }
00581         if ($adofield->max_length > 0 &&
00582                ($this->type == XMLDB_TYPE_INTEGER ||
00583                 $this->type == XMLDB_TYPE_NUMBER  ||
00584                 $this->type == XMLDB_TYPE_FLOAT   ||
00585                 $this->type == XMLDB_TYPE_CHAR)) {
00586             $this->length = $adofield->max_length;
00587         }
00588         if ($this->type == XMLDB_TYPE_TEXT) {
00589             switch (strtolower($adofield->type)) {
00590                 case 'tinytext':
00591                 case 'text':
00592                     $this->length = 'small';
00593                     break;
00594                 case 'mediumtext':
00595                     $this->length = 'medium';
00596                     break;
00597                 case 'longtext':
00598                     $this->length = 'big';
00599                     break;
00600                 default:
00601                     $this->length = 'small';
00602             }
00603         }
00604         if ($this->type == XMLDB_TYPE_BINARY) {
00605             switch (strtolower($adofield->type)) {
00606                 case 'tinyblob':
00607                 case 'blob':
00608                     $this->length = 'small';
00609                     break;
00610                 case 'mediumblob':
00611                     $this->length = 'medium';
00612                     break;
00613                 case 'longblob':
00614                     $this->length = 'big';
00615                     break;
00616                 default:
00617                     $this->length = 'small';
00618             }
00619         }
00621         if ($adofield->max_length > 0 &&
00622             $adofield->scale &&
00623                ($this->type == XMLDB_TYPE_NUMBER ||
00624                 $this->type == XMLDB_TYPE_FLOAT)) {
00625             $this->decimals = $adofield->scale;
00626         }
00628         if ($adofield->unsigned &&
00629                ($this->type == XMLDB_TYPE_INTEGER ||
00630                 $this->type == XMLDB_TYPE_NUMBER  ||
00631                 $this->type == XMLDB_TYPE_FLOAT)) {
00632             $this->unsigned = true;
00633         }
00635         if ($adofield->not_null) {
00636             $this->notnull = true;
00637         }
00639         if ($adofield->has_default) {
00640             $this->default = $adofield->default_value;
00641         }
00643         if ($adofield->auto_increment) {
00644             $this->sequence = true;
00646             $this->unsigned = true;
00647         }
00649         $this->loaded = true;
00650         $this->changed = true;
00651     }
00652 
00656     function getPHP($includeprevious=true) {
00657 
00658         $result = '';
00659 
00661         switch ($this->getType()) {
00662             case XMLDB_TYPE_INTEGER:
00663                 $result .= 'XMLDB_TYPE_INTEGER' . ', ';
00664                 break;
00665             case XMLDB_TYPE_NUMBER:
00666                 $result .= 'XMLDB_TYPE_NUMBER' . ', ';
00667                 break;
00668             case XMLDB_TYPE_FLOAT:
00669                 $result .= 'XMLDB_TYPE_FLOAT' . ', ';
00670                 break;
00671             case XMLDB_TYPE_CHAR:
00672                 $result .= 'XMLDB_TYPE_CHAR' . ', ';
00673                 break;
00674             case XMLDB_TYPE_TEXT:
00675                 $result .= 'XMLDB_TYPE_TEXT' . ', ';
00676                 break;
00677             case XMLDB_TYPE_BINARY:
00678                 $result .= 'XMLDB_TYPE_BINARY' . ', ';
00679                 break;
00680             case XMLDB_TYPE_DATETIME:
00681                 $result .= 'XMLDB_TYPE_DATETIME' . ', ';
00682                 break;
00683             case XMLDB_TYPE_TIMESTAMP:
00684                 $result .= 'XMLDB_TYPE_TIMESTAMP' . ', ';
00685                 break;
00686         }
00688         $length = $this->getLength();
00689         $decimals = $this->getDecimals();
00690         if (!empty($length)) {
00691             $result .= "'" . $length;
00692             if (!empty($decimals)) {
00693                 $result .= ', ' . $decimals;
00694             }
00695             $result .= "', ";
00696         } else {
00697             $result .= 'null, ';
00698         }
00700         $unsigned = $this->getUnsigned();
00701         if (!empty($unsigned) &&
00702            ($this->getType() == XMLDB_TYPE_INTEGER || $this->getType() == XMLDB_TYPE_NUMBER || $this->getType() == XMLDB_TYPE_FLOAT)) {
00703             $result .= 'XMLDB_UNSIGNED' . ', ';
00704         } else {
00705             $result .= 'null, ';
00706         }
00708         $notnull = $this->getNotnull();
00709         if (!empty($notnull)) {
00710             $result .= 'XMLDB_NOTNULL' . ', ';
00711         } else {
00712             $result .= 'null, ';
00713         }
00715         $sequence = $this->getSequence();
00716         if (!empty($sequence)) {
00717             $result .= 'XMLDB_SEQUENCE' . ', ';
00718         } else {
00719             $result .= 'null, ';
00720         }
00722         $default =  $this->getDefault();
00723         if ($default !== null && !$this->getSequence()) {
00724             $result .= "'" . $default . "'";
00725         } else {
00726             $result .= 'null';
00727         }
00729         if ($includeprevious) {
00730             $previous = $this->getPrevious();
00731             if (!empty($previous)) {
00732                 $result .= ", '" . $previous . "'";
00733             } else {
00734                 $result .= ', null';
00735             }
00736         }
00738         return $result;
00739     }
00740 
00744     function readableInfo() {
00745         $o = '';
00747         $o .= $this->getXMLDBTypeName($this->type);
00749         if ($this->type == XMLDB_TYPE_INTEGER ||
00750             $this->type == XMLDB_TYPE_NUMBER  ||
00751             $this->type == XMLDB_TYPE_FLOAT   ||
00752             $this->type == XMLDB_TYPE_CHAR) {
00753             if ($this->length) {
00754                 $o .= ' (' . $this->length;
00755                 if ($this->type == XMLDB_TYPE_NUMBER  ||
00756                     $this->type == XMLDB_TYPE_FLOAT) {
00757                     if ($this->decimals !== NULL) {
00758                         $o .= ', ' . $this->decimals;
00759                     }
00760                 }
00761                 $o .= ')';
00762             }
00763         }
00764         if ($this->type == XMLDB_TYPE_TEXT ||
00765             $this->type == XMLDB_TYPE_BINARY) {
00766                 $o .= ' (' . $this->length . ')';
00767         }
00769         if ($this->type == XMLDB_TYPE_INTEGER ||
00770             $this->type == XMLDB_TYPE_NUMBER ||
00771             $this->type == XMLDB_TYPE_FLOAT) {
00772             if ($this->unsigned) {
00773                 $o .= ' unsigned';
00774             } else {
00775                 $o .= ' signed';
00776             }
00777         }
00779         if ($this->notnull) {
00780             $o .= ' not null';
00781         }
00783         if ($this->default !== NULL) {
00784             $o .= ' default ';
00785             if ($this->type == XMLDB_TYPE_CHAR ||
00786                 $this->type == XMLDB_TYPE_TEXT) {
00787                     $o .= "'" . $this->default . "'";
00788             } else {
00789                 $o .= $this->default;
00790             }
00791         }
00793         if ($this->sequence) {
00794             $o .= ' auto-numbered';
00795         }
00796 
00797         return $o;
00798     }
00799 
00809     function validateDefinition(xmldb_table $xmldb_table=null) {
00810         if (!$xmldb_table) {
00811             return 'Invalid xmldb_field->validateDefinition() call, $xmldb_table si required.';
00812         }
00813 
00814         switch ($this->getType()) {
00815             case XMLDB_TYPE_INTEGER:
00816                 break;
00817 
00818             case XMLDB_TYPE_NUMBER:
00819                 break;
00820 
00821             case XMLDB_TYPE_FLOAT:
00822                 break;
00823 
00824             case XMLDB_TYPE_CHAR:
00825                 if ($this->getLength() > self::CHAR_MAX_LENGTH) {
00826                     return 'Invalid field definition in table {'.$xmldb_table->getName(). '}: XMLDB_TYPE_CHAR field "'.$this->getName().'" is too long.'
00827                            .' Limit is '.self::CHAR_MAX_LENGTH.' chars.';
00828                 }
00829                 break;
00830 
00831             case XMLDB_TYPE_TEXT:
00832                 break;
00833 
00834             case XMLDB_TYPE_BINARY:
00835                 break;
00836 
00837             case XMLDB_TYPE_DATETIME:
00838                 break;
00839 
00840             case XMLDB_TYPE_TIMESTAMP:
00841                 break;
00842         }
00843 
00844         return null;
00845     }
00846 }
00847 
00850 class XMLDBField extends xmldb_field {
00851 
00852     function __construct($name) {
00853         parent::__construct($name);
00854     }
00855 
00856 }
 All Data Structures Namespaces Files Functions Variables Enumerations