TableBase.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. // @docs in Schema_TableFactory
  3. class Schema_TableBase {
  4. public $idDatabase;
  5. public $tblName;
  6. public function __construct($idDatabase, $tblName) {
  7. $this->idDatabase = $idDatabase;
  8. $this->tblName = strtolower($tblName);
  9. $this->_types = array();
  10. $this->_restrictions = array();
  11. $this->initTypes();
  12. }
  13. public function initTypes() {// TODO: override
  14. // parent::initTypes();// always call parent method
  15. // example: $this->_types['WWW'] = 'p5:www_link';
  16. // example: $this->_restrictions['WWW'] = ['maxLength' => 255]
  17. // TODO:? $this->_types['WWW'] = new Type_Link($params = ['maxLength' => 255, ...]);
  18. }
  19. public function fixTypes($types) {
  20. if (empty($this->_types)) return $types;
  21. foreach ($types as $fldName => $type) {
  22. if (array_key_exists($fldName, $this->_types)) {
  23. $types[$fldName]['simpleType'] = $this->_types[$fldName];
  24. }
  25. if (array_key_exists($fldName, $this->_restrictions)) {
  26. $types[$fldName]['restrictions'] = $this->_restrictions[$fldName];
  27. }
  28. // TODO: add default xsdElementType('simpleType', 'complexType'), xsdType(p5Type:...), ... for every field
  29. }
  30. return $types;
  31. }
  32. }