ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

adodb-xmlschema.inc.php
Go to the documentation of this file.
1 <?php
2 // Copyright (c) 2004 ars Cognita Inc., all rights reserved
3 /* ******************************************************************************
4  Released under both BSD license and Lesser GPL library license.
5  Whenever there is any discrepancy between the two licenses,
6  the BSD license will take precedence.
7 *******************************************************************************/
21 function _file_get_contents($file)
22 {
23  if (function_exists('file_get_contents')) return file_get_contents($file);
24 
25  $f = fopen($file,'r');
26  if (!$f) return '';
27  $t = '';
28 
29  while ($s = fread($f,100000)) $t .= $s;
30  fclose($f);
31  return $t;
32 }
33 
34 
38 if( !defined( 'XMLS_DEBUG' ) ) {
39  define( 'XMLS_DEBUG', FALSE );
40 }
41 
45 if( !defined( 'XMLS_PREFIX' ) ) {
46  define( 'XMLS_PREFIX', '%%P' );
47 }
48 
52 if( !defined( 'XMLS_PREFIX_MAXLEN' ) ) {
53  define( 'XMLS_PREFIX_MAXLEN', 10 );
54 }
55 
59 if( !defined( 'XMLS_EXECUTE_INLINE' ) ) {
60  define( 'XMLS_EXECUTE_INLINE', FALSE );
61 }
62 
66 if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) ) {
67  define( 'XMLS_CONTINUE_ON_ERROR', FALSE );
68 }
69 
73 if( !defined( 'XMLS_SCHEMA_VERSION' ) ) {
74  define( 'XMLS_SCHEMA_VERSION', '0.2' );
75 }
76 
80 if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) ) {
81  define( 'XMLS_DEFAULT_SCHEMA_VERSION', '0.1' );
82 }
83 
87 if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
88  define( 'XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER' );
89 }
90 
94 if( !defined( '_ADODB_LAYER' ) ) {
95  require( 'adodb.inc.php' );
96  require( 'adodb-datadict.inc.php' );
97 }
98 
106 class dbObject {
107 
111  var $parent;
112 
117 
121  function __construct( &$parent, $attributes = NULL ) {
122  $this->parent = $parent;
123  }
124 
130  function _tag_open( &$parser, $tag, $attributes ) {
131 
132  }
133 
139  function _tag_cdata( &$parser, $cdata ) {
140 
141  }
142 
148  function _tag_close( &$parser, $tag ) {
149 
150  }
151 
152  function create(&$xmls) {
153  return array();
154  }
155 
159  function destroy() {
160  }
161 
169  function supportedPlatform( $platform = NULL ) {
170  return is_object( $this->parent ) ? $this->parent->supportedPlatform( $platform ) : TRUE;
171  }
172 
179  function prefix( $name = '' ) {
180  return is_object( $this->parent ) ? $this->parent->prefix( $name ) : $name;
181  }
182 
189  function FieldID( $field ) {
190  return strtoupper( preg_replace( '/^`(.+)`$/', '$1', $field ) );
191  }
192 }
193 
205 class dbTable extends dbObject {
206 
210  var $name;
211 
215  var $fields = array();
216 
220  var $indexes = array();
221 
225  var $opts = array();
226 
231 
237 
242  var $drop_field = array();
243 
250  function __construct( &$parent, $attributes = NULL ) {
251  $this->parent = $parent;
252  $this->name = $this->prefix($attributes['NAME']);
253  }
254 
261  function _tag_open( &$parser, $tag, $attributes ) {
262  $this->currentElement = strtoupper( $tag );
263 
264  switch( $this->currentElement ) {
265  case 'INDEX':
266  if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
267  $index = $this->addIndex( $attributes );
268  xml_set_object( $parser, $index );
269  }
270  break;
271  case 'DATA':
272  if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
273  $data = $this->addData( $attributes );
274  xml_set_object( $parser, $data );
275  }
276  break;
277  case 'DROP':
278  $this->drop();
279  break;
280  case 'FIELD':
281  // Add a field
282  $fieldName = $attributes['NAME'];
283  $fieldType = $attributes['TYPE'];
284  $fieldSize = isset( $attributes['SIZE'] ) ? $attributes['SIZE'] : NULL;
285  $fieldOpts = isset( $attributes['OPTS'] ) ? $attributes['OPTS'] : NULL;
286 
287  $this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
288  break;
289  case 'KEY':
290  case 'NOTNULL':
291  case 'AUTOINCREMENT':
292  // Add a field option
293  $this->addFieldOpt( $this->current_field, $this->currentElement );
294  break;
295  case 'DEFAULT':
296  // Add a field option to the table object
297 
298  // Work around ADOdb datadict issue that misinterprets empty strings.
299  if( $attributes['VALUE'] == '' ) {
300  $attributes['VALUE'] = " '' ";
301  }
302 
303  $this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
304  break;
305  case 'DEFDATE':
306  case 'DEFTIMESTAMP':
307  // Add a field option to the table object
308  $this->addFieldOpt( $this->current_field, $this->currentElement );
309  break;
310  default:
311  // print_r( array( $tag, $attributes ) );
312  }
313  }
314 
320  function _tag_cdata( &$parser, $cdata ) {
321  switch( $this->currentElement ) {
322  // Table constraint
323  case 'CONSTRAINT':
324  if( isset( $this->current_field ) ) {
325  $this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
326  } else {
327  $this->addTableOpt( $cdata );
328  }
329  break;
330  // Table option
331  case 'OPT':
332  $this->addTableOpt( $cdata );
333  break;
334  default:
335 
336  }
337  }
338 
344  function _tag_close( &$parser, $tag ) {
345  $this->currentElement = '';
346 
347  switch( strtoupper( $tag ) ) {
348  case 'TABLE':
349  $this->parent->addSQL( $this->create( $this->parent ) );
350  xml_set_object( $parser, $this->parent );
351  $this->destroy();
352  break;
353  case 'FIELD':
354  unset($this->current_field);
355  break;
356 
357  }
358  }
359 
366  function addIndex( $attributes ) {
367  $name = strtoupper( $attributes['NAME'] );
368  $this->indexes[$name] = new dbIndex( $this, $attributes );
369  return $this->indexes[$name];
370  }
371 
378  function addData( $attributes ) {
379  if( !isset( $this->data ) ) {
380  $this->data = new dbData( $this, $attributes );
381  }
382  return $this->data;
383  }
384 
414  function addField( $name, $type, $size = NULL, $opts = NULL ) {
415  $field_id = $this->FieldID( $name );
416 
417  // Set the field index so we know where we are
418  $this->current_field = $field_id;
419 
420  // Set the field name (required)
421  $this->fields[$field_id]['NAME'] = $name;
422 
423  // Set the field type (required)
424  $this->fields[$field_id]['TYPE'] = $type;
425 
426  // Set the field size (optional)
427  if( isset( $size ) ) {
428  $this->fields[$field_id]['SIZE'] = $size;
429  }
430 
431  // Set the field options
432  if( isset( $opts ) ) {
433  $this->fields[$field_id]['OPTS'][] = $opts;
434  }
435  }
436 
448  function addFieldOpt( $field, $opt, $value = NULL ) {
449  if( !isset( $value ) ) {
450  $this->fields[$this->FieldID( $field )]['OPTS'][] = $opt;
451  // Add the option and value
452  } else {
453  $this->fields[$this->FieldID( $field )]['OPTS'][] = array( $opt => $value );
454  }
455  }
456 
466  function addTableOpt( $opt ) {
467  if(isset($this->currentPlatform)) {
468  $this->opts[$this->parent->db->databaseType] = $opt;
469  }
470  return $this->opts;
471  }
472 
473 
480  function create( &$xmls ) {
481  $sql = array();
482 
483  // drop any existing indexes
484  if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) {
485  foreach( $legacy_indexes as $index => $index_details ) {
486  $sql[] = $xmls->dict->DropIndexSQL( $index, $this->name );
487  }
488  }
489 
490  // remove fields to be dropped from table object
491  foreach( $this->drop_field as $field ) {
492  unset( $this->fields[$field] );
493  }
494 
495  // if table exists
496  if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) {
497  // drop table
498  if( $this->drop_table ) {
499  $sql[] = $xmls->dict->DropTableSQL( $this->name );
500 
501  return $sql;
502  }
503 
504  // drop any existing fields not in schema
505  foreach( $legacy_fields as $field_id => $field ) {
506  if( !isset( $this->fields[$field_id] ) ) {
507  $sql[] = $xmls->dict->DropColumnSQL( $this->name, '`'.$field->name.'`' );
508  }
509  }
510  // if table doesn't exist
511  } else {
512  if( $this->drop_table ) {
513  return $sql;
514  }
515 
516  $legacy_fields = array();
517  }
518 
519  // Loop through the field specifier array, building the associative array for the field options
520  $fldarray = array();
521 
522  foreach( $this->fields as $field_id => $finfo ) {
523  // Set an empty size if it isn't supplied
524  if( !isset( $finfo['SIZE'] ) ) {
525  $finfo['SIZE'] = '';
526  }
527 
528  // Initialize the field array with the type and size
529  $fldarray[$field_id] = array(
530  'NAME' => $finfo['NAME'],
531  'TYPE' => $finfo['TYPE'],
532  'SIZE' => $finfo['SIZE']
533  );
534 
535  // Loop through the options array and add the field options.
536  if( isset( $finfo['OPTS'] ) ) {
537  foreach( $finfo['OPTS'] as $opt ) {
538  // Option has an argument.
539  if( is_array( $opt ) ) {
540  $key = key( $opt );
541  $value = $opt[key( $opt )];
542  @$fldarray[$field_id][$key] .= $value;
543  // Option doesn't have arguments
544  } else {
545  $fldarray[$field_id][$opt] = $opt;
546  }
547  }
548  }
549  }
550 
551  if( empty( $legacy_fields ) ) {
552  // Create the new table
553  $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
554  logMsg( end( $sql ), 'Generated CreateTableSQL' );
555  } else {
556  // Upgrade an existing table
557  logMsg( "Upgrading {$this->name} using '{$xmls->upgrade}'" );
558  switch( $xmls->upgrade ) {
559  // Use ChangeTableSQL
560  case 'ALTER':
561  logMsg( 'Generated ChangeTableSQL (ALTERing table)' );
562  $sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts );
563  break;
564  case 'REPLACE':
565  logMsg( 'Doing upgrade REPLACE (testing)' );
566  $sql[] = $xmls->dict->DropTableSQL( $this->name );
567  $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
568  break;
569  // ignore table
570  default:
571  return array();
572  }
573  }
574 
575  foreach( $this->indexes as $index ) {
576  $sql[] = $index->create( $xmls );
577  }
578 
579  if( isset( $this->data ) ) {
580  $sql[] = $this->data->create( $xmls );
581  }
582 
583  return $sql;
584  }
585 
589  function drop() {
590  if( isset( $this->current_field ) ) {
591  // Drop the current field
592  logMsg( "Dropping field '{$this->current_field}' from table '{$this->name}'" );
593  // $this->drop_field[$this->current_field] = $xmls->dict->DropColumnSQL( $this->name, $this->current_field );
594  $this->drop_field[$this->current_field] = $this->current_field;
595  } else {
596  // Drop the current table
597  logMsg( "Dropping table '{$this->name}'" );
598  // $this->drop_table = $xmls->dict->DropTableSQL( $this->name );
599  $this->drop_table = TRUE;
600  }
601  }
602 }
603 
615 class dbIndex extends dbObject {
616 
620  var $name;
621 
625  var $opts = array();
626 
630  var $columns = array();
631 
636  var $drop = FALSE;
637 
646  function __construct( &$parent, $attributes = NULL ) {
647  $this->parent = $parent;
648 
649  $this->name = $this->prefix ($attributes['NAME']);
650  }
651 
660  function _tag_open( &$parser, $tag, $attributes ) {
661  $this->currentElement = strtoupper( $tag );
662 
663  switch( $this->currentElement ) {
664  case 'DROP':
665  $this->drop();
666  break;
667  case 'CLUSTERED':
668  case 'BITMAP':
669  case 'UNIQUE':
670  case 'FULLTEXT':
671  case 'HASH':
672  // Add index Option
673  $this->addIndexOpt( $this->currentElement );
674  break;
675  default:
676  // print_r( array( $tag, $attributes ) );
677  }
678  }
679 
687  function _tag_cdata( &$parser, $cdata ) {
688  switch( $this->currentElement ) {
689  // Index field name
690  case 'COL':
691  $this->addField( $cdata );
692  break;
693  default:
694 
695  }
696  }
697 
703  function _tag_close( &$parser, $tag ) {
704  $this->currentElement = '';
705 
706  switch( strtoupper( $tag ) ) {
707  case 'INDEX':
708  xml_set_object( $parser, $this->parent );
709  break;
710  }
711  }
712 
719  function addField( $name ) {
720  $this->columns[$this->FieldID( $name )] = $name;
721 
722  // Return the field list
723  return $this->columns;
724  }
725 
732  function addIndexOpt( $opt ) {
733  $this->opts[] = $opt;
734 
735  // Return the options list
736  return $this->opts;
737  }
738 
745  function create( &$xmls ) {
746  if( $this->drop ) {
747  return NULL;
748  }
749 
750  // eliminate any columns that aren't in the table
751  foreach( $this->columns as $id => $col ) {
752  if( !isset( $this->parent->fields[$id] ) ) {
753  unset( $this->columns[$id] );
754  }
755  }
756 
757  return $xmls->dict->CreateIndexSQL( $this->name, $this->parent->name, $this->columns, $this->opts );
758  }
759 
763  function drop() {
764  $this->drop = TRUE;
765  }
766 }
767 
776 class dbData extends dbObject {
777 
778  var $data = array();
779 
780  var $row;
781 
790  function __construct( &$parent, $attributes = NULL ) {
791  $this->parent = $parent;
792  }
793 
802  function _tag_open( &$parser, $tag, $attributes ) {
803  $this->currentElement = strtoupper( $tag );
804 
805  switch( $this->currentElement ) {
806  case 'ROW':
807  $this->row = count( $this->data );
808  $this->data[$this->row] = array();
809  break;
810  case 'F':
811  $this->addField($attributes);
812  default:
813  // print_r( array( $tag, $attributes ) );
814  }
815  }
816 
824  function _tag_cdata( &$parser, $cdata ) {
825  switch( $this->currentElement ) {
826  // Index field name
827  case 'F':
828  $this->addData( $cdata );
829  break;
830  default:
831 
832  }
833  }
834 
840  function _tag_close( &$parser, $tag ) {
841  $this->currentElement = '';
842 
843  switch( strtoupper( $tag ) ) {
844  case 'DATA':
845  xml_set_object( $parser, $this->parent );
846  break;
847  }
848  }
849 
856  function addField( $attributes ) {
857  if( isset( $attributes['NAME'] ) ) {
858  $name = $attributes['NAME'];
859  } else {
860  $name = count($this->data[$this->row]);
861  }
862 
863  // Set the field index so we know where we are
864  $this->current_field = $this->FieldID( $name );
865  }
866 
873  function addData( $cdata ) {
874  if( !isset( $this->data[$this->row] ) ) {
875  $this->data[$this->row] = array();
876  }
877 
878  if( !isset( $this->data[$this->row][$this->current_field] ) ) {
879  $this->data[$this->row][$this->current_field] = '';
880  }
881 
882  $this->data[$this->row][$this->current_field] .= $cdata;
883  }
884 
891  function create( &$xmls ) {
892  $table = $xmls->dict->TableName($this->parent->name);
893  $table_field_count = count($this->parent->fields);
894  $sql = array();
895 
896  // eliminate any columns that aren't in the table
897  foreach( $this->data as $row ) {
898  $table_fields = $this->parent->fields;
899  $fields = array();
900 
901  foreach( $row as $field_id => $field_data ) {
902  if( !array_key_exists( $field_id, $table_fields ) ) {
903  if( is_numeric( $field_id ) ) {
904  $field_id = reset( array_keys( $table_fields ) );
905  } else {
906  continue;
907  }
908  }
909 
910  $name = $table_fields[$field_id]['NAME'];
911 
912  switch( $table_fields[$field_id]['TYPE'] ) {
913  case 'C':
914  case 'C2':
915  case 'X':
916  case 'X2':
917  $fields[$name] = $xmls->db->qstr( $field_data );
918  break;
919  case 'I':
920  case 'I1':
921  case 'I2':
922  case 'I4':
923  case 'I8':
924  $fields[$name] = intval($field_data);
925  break;
926  default:
927  $fields[$name] = $field_data;
928  }
929 
930  unset($table_fields[$field_id]);
931  }
932 
933  // check that at least 1 column is specified
934  if( empty( $fields ) ) {
935  continue;
936  }
937 
938  // check that no required columns are missing
939  if( count( $fields ) < $table_field_count ) {
940  foreach( $table_fields as $field ) {
941  if (isset( $field['OPTS'] ))
942  if( ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) {
943  continue(2);
944  }
945  }
946  }
947 
948  $sql[] = 'INSERT INTO '. $table .' ('. implode( ',', array_keys( $fields ) ) .') VALUES ('. implode( ',', $fields ) .')';
949  }
950 
951  return $sql;
952  }
953 }
954 
961 class dbQuerySet extends dbObject {
962 
966  var $queries = array();
967 
971  var $query;
972 
976  var $prefixKey = '';
977 
981  var $prefixMethod = 'AUTO';
982 
989  function __construct( &$parent, $attributes = NULL ) {
990  $this->parent = $parent;
991 
992  // Overrides the manual prefix key
993  if( isset( $attributes['KEY'] ) ) {
994  $this->prefixKey = $attributes['KEY'];
995  }
996 
997  $prefixMethod = isset( $attributes['PREFIXMETHOD'] ) ? strtoupper( trim( $attributes['PREFIXMETHOD'] ) ) : '';
998 
999  // Enables or disables automatic prefix prepending
1000  switch( $prefixMethod ) {
1001  case 'AUTO':
1002  $this->prefixMethod = 'AUTO';
1003  break;
1004  case 'MANUAL':
1005  $this->prefixMethod = 'MANUAL';
1006  break;
1007  case 'NONE':
1008  $this->prefixMethod = 'NONE';
1009  break;
1010  }
1011  }
1012 
1019  function _tag_open( &$parser, $tag, $attributes ) {
1020  $this->currentElement = strtoupper( $tag );
1021 
1022  switch( $this->currentElement ) {
1023  case 'QUERY':
1024  // Create a new query in a SQL queryset.
1025  // Ignore this query set if a platform is specified and it's different than the
1026  // current connection platform.
1027  if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1028  $this->newQuery();
1029  } else {
1030  $this->discardQuery();
1031  }
1032  break;
1033  default:
1034  // print_r( array( $tag, $attributes ) );
1035  }
1036  }
1037 
1041  function _tag_cdata( &$parser, $cdata ) {
1042  switch( $this->currentElement ) {
1043  // Line of queryset SQL data
1044  case 'QUERY':
1045  $this->buildQuery( $cdata );
1046  break;
1047  default:
1048 
1049  }
1050  }
1051 
1057  function _tag_close( &$parser, $tag ) {
1058  $this->currentElement = '';
1059 
1060  switch( strtoupper( $tag ) ) {
1061  case 'QUERY':
1062  // Add the finished query to the open query set.
1063  $this->addQuery();
1064  break;
1065  case 'SQL':
1066  $this->parent->addSQL( $this->create( $this->parent ) );
1067  xml_set_object( $parser, $this->parent );
1068  $this->destroy();
1069  break;
1070  default:
1071 
1072  }
1073  }
1074 
1080  function newQuery() {
1081  $this->query = '';
1082 
1083  return TRUE;
1084  }
1085 
1091  function discardQuery() {
1092  unset( $this->query );
1093 
1094  return TRUE;
1095  }
1096 
1103  function buildQuery( $sql = NULL ) {
1104  if( !isset( $this->query ) OR empty( $sql ) ) {
1105  return FALSE;
1106  }
1107 
1108  $this->query .= $sql;
1109 
1110  return $this->query;
1111  }
1112 
1118  function addQuery() {
1119  if( !isset( $this->query ) ) {
1120  return FALSE;
1121  }
1122 
1123  $this->queries[] = $return = trim($this->query);
1124 
1125  unset( $this->query );
1126 
1127  return $return;
1128  }
1129 
1136  function create( &$xmls ) {
1137  foreach( $this->queries as $id => $query ) {
1138  switch( $this->prefixMethod ) {
1139  case 'AUTO':
1140  // Enable auto prefix replacement
1141 
1142  // Process object prefix.
1143  // Evaluate SQL statements to prepend prefix to objects
1144  $query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
1145  $query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
1146  $query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
1147 
1148  // SELECT statements aren't working yet
1149  #$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data );
1150 
1151  case 'MANUAL':
1152  // If prefixKey is set and has a value then we use it to override the default constant XMLS_PREFIX.
1153  // If prefixKey is not set, we use the default constant XMLS_PREFIX
1154  if( isset( $this->prefixKey ) AND( $this->prefixKey !== '' ) ) {
1155  // Enable prefix override
1156  $query = str_replace( $this->prefixKey, $xmls->objectPrefix, $query );
1157  } else {
1158  // Use default replacement
1159  $query = str_replace( XMLS_PREFIX , $xmls->objectPrefix, $query );
1160  }
1161  }
1162 
1163  $this->queries[$id] = trim( $query );
1164  }
1165 
1166  // Return the query set array
1167  return $this->queries;
1168  }
1169 
1178  function prefixQuery( $regex, $query, $prefix = NULL ) {
1179  if( !isset( $prefix ) ) {
1180  return $query;
1181  }
1182 
1183  if( preg_match( $regex, $query, $match ) ) {
1184  $preamble = $match[1];
1185  $postamble = $match[5];
1186  $objectList = explode( ',', $match[3] );
1187  // $prefix = $prefix . '_';
1188 
1189  $prefixedList = '';
1190 
1191  foreach( $objectList as $object ) {
1192  if( $prefixedList !== '' ) {
1193  $prefixedList .= ', ';
1194  }
1195 
1196  $prefixedList .= $prefix . trim( $object );
1197  }
1198 
1199  $query = $preamble . ' ' . $prefixedList . ' ' . $postamble;
1200  }
1201 
1202  return $query;
1203  }
1204 }
1205 
1219 class adoSchema {
1220 
1226 
1231  var $db;
1232 
1237  var $dict;
1238 
1244 
1249  var $upgrade = '';
1250 
1255  var $objectPrefix = '';
1256 
1261  var $mgq;
1262 
1267  var $debug;
1268 
1273  var $versionRegex = '/<schema.*?( version="([^"]*)")?.*?>/';
1274 
1280 
1285 
1290 
1295 
1305  function __construct( $db ) {
1306  // Initialize the environment
1307  $this->mgq = get_magic_quotes_runtime();
1308  ini_set("magic_quotes_runtime", 0);
1309  #set_magic_quotes_runtime(0);
1310 
1311  $this->db = $db;
1312  $this->debug = $this->db->debug;
1313  $this->dict = NewDataDictionary( $this->db );
1314  $this->sqlArray = array();
1315  $this->schemaVersion = XMLS_SCHEMA_VERSION;
1316  $this->executeInline( XMLS_EXECUTE_INLINE );
1317  $this->continueOnError( XMLS_CONTINUE_ON_ERROR );
1318  $this->setUpgradeMethod();
1319  }
1320 
1337  function SetUpgradeMethod( $method = '' ) {
1338  if( !is_string( $method ) ) {
1339  return FALSE;
1340  }
1341 
1342  $method = strtoupper( $method );
1343 
1344  // Handle the upgrade methods
1345  switch( $method ) {
1346  case 'ALTER':
1347  $this->upgrade = $method;
1348  break;
1349  case 'REPLACE':
1350  $this->upgrade = $method;
1351  break;
1352  case 'BEST':
1353  $this->upgrade = 'ALTER';
1354  break;
1355  case 'NONE':
1356  $this->upgrade = 'NONE';
1357  break;
1358  default:
1359  // Use default if no legitimate method is passed.
1360  $this->upgrade = XMLS_DEFAULT_UPGRADE_METHOD;
1361  }
1362 
1363  return $this->upgrade;
1364  }
1365 
1379  function ExecuteInline( $mode = NULL ) {
1380  if( is_bool( $mode ) ) {
1381  $this->executeInline = $mode;
1382  }
1383 
1384  return $this->executeInline;
1385  }
1386 
1400  function ContinueOnError( $mode = NULL ) {
1401  if( is_bool( $mode ) ) {
1402  $this->continueOnError = $mode;
1403  }
1404 
1405  return $this->continueOnError;
1406  }
1407 
1419  function ParseSchema( $filename, $returnSchema = FALSE ) {
1420  return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1421  }
1422 
1436  function ParseSchemaFile( $filename, $returnSchema = FALSE ) {
1437  // Open the file
1438  if( !($fp = fopen( $filename, 'r' )) ) {
1439  // die( 'Unable to open file' );
1440  return FALSE;
1441  }
1442 
1443  // do version detection here
1444  if( $this->SchemaFileVersion( $filename ) != $this->schemaVersion ) {
1445  return FALSE;
1446  }
1447 
1448  if ( $returnSchema )
1449  {
1450  $xmlstring = '';
1451  while( $data = fread( $fp, 100000 ) ) {
1452  $xmlstring .= $data;
1453  }
1454  return $xmlstring;
1455  }
1456 
1457  $this->success = 2;
1458 
1459  $xmlParser = $this->create_parser();
1460 
1461  // Process the file
1462  while( $data = fread( $fp, 4096 ) ) {
1463  if( !xml_parse( $xmlParser, $data, feof( $fp ) ) ) {
1464  die( sprintf(
1465  "XML error: %s at line %d",
1466  xml_error_string( xml_get_error_code( $xmlParser) ),
1467  xml_get_current_line_number( $xmlParser)
1468  ) );
1469  }
1470  }
1471 
1472  xml_parser_free( $xmlParser );
1473 
1474  return $this->sqlArray;
1475  }
1476 
1488  function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) {
1489  if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1490  return FALSE;
1491  }
1492 
1493  // do version detection here
1494  if( $this->SchemaStringVersion( $xmlstring ) != $this->schemaVersion ) {
1495  return FALSE;
1496  }
1497 
1498  if ( $returnSchema )
1499  {
1500  return $xmlstring;
1501  }
1502 
1503  $this->success = 2;
1504 
1505  $xmlParser = $this->create_parser();
1506 
1507  if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) {
1508  die( sprintf(
1509  "XML error: %s at line %d",
1510  xml_error_string( xml_get_error_code( $xmlParser) ),
1511  xml_get_current_line_number( $xmlParser)
1512  ) );
1513  }
1514 
1515  xml_parser_free( $xmlParser );
1516 
1517  return $this->sqlArray;
1518  }
1519 
1531  function RemoveSchema( $filename, $returnSchema = FALSE ) {
1532  return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1533  }
1534 
1546  function RemoveSchemaString( $schema, $returnSchema = FALSE ) {
1547 
1548  // grab current version
1549  if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
1550  return FALSE;
1551  }
1552 
1553  return $this->ParseSchemaString( $this->TransformSchema( $schema, 'remove-' . $version), $returnSchema );
1554  }
1555 
1569  function ExecuteSchema( $sqlArray = NULL, $continueOnErr = NULL ) {
1570  if( !is_bool( $continueOnErr ) ) {
1571  $continueOnErr = $this->ContinueOnError();
1572  }
1573 
1574  if( !isset( $sqlArray ) ) {
1576  }
1577 
1578  if( !is_array( $sqlArray ) ) {
1579  $this->success = 0;
1580  } else {
1581  $this->success = $this->dict->ExecuteSQLArray( $sqlArray, $continueOnErr );
1582  }
1583 
1584  return $this->success;
1585  }
1586 
1596  function PrintSQL( $format = 'NONE' ) {
1597  $sqlArray = null;
1598  return $this->getSQL( $format, $sqlArray );
1599  }
1600 
1610  function SaveSQL( $filename = './schema.sql' ) {
1611 
1612  if( !isset( $sqlArray ) ) {
1614  }
1615  if( !isset( $sqlArray ) ) {
1616  return FALSE;
1617  }
1618 
1619  $fp = fopen( $filename, "w" );
1620 
1621  foreach( $sqlArray as $key => $query ) {
1622  fwrite( $fp, $query . ";\n" );
1623  }
1624  fclose( $fp );
1625  }
1626 
1634  function create_parser() {
1635  // Create the parser
1636  $xmlParser = xml_parser_create();
1637  xml_set_object( $xmlParser, $this );
1638 
1639  // Initialize the XML callback functions
1640  xml_set_element_handler( $xmlParser, '_tag_open', '_tag_close' );
1641  xml_set_character_data_handler( $xmlParser, '_tag_cdata' );
1642 
1643  return $xmlParser;
1644  }
1645 
1651  function _tag_open( &$parser, $tag, $attributes ) {
1652  switch( strtoupper( $tag ) ) {
1653  case 'TABLE':
1654  $this->obj = new dbTable( $this, $attributes );
1655  xml_set_object( $parser, $this->obj );
1656  break;
1657  case 'SQL':
1658  if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
1659  $this->obj = new dbQuerySet( $this, $attributes );
1660  xml_set_object( $parser, $this->obj );
1661  }
1662  break;
1663  default:
1664  // print_r( array( $tag, $attributes ) );
1665  }
1666 
1667  }
1668 
1674  function _tag_cdata( &$parser, $cdata ) {
1675  }
1676 
1683  function _tag_close( &$parser, $tag ) {
1684 
1685  }
1686 
1703  function ConvertSchemaString( $schema, $newVersion = NULL, $newFile = NULL ) {
1704 
1705  // grab current version
1706  if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
1707  return FALSE;
1708  }
1709 
1710  if( !isset ($newVersion) ) {
1711  $newVersion = $this->schemaVersion;
1712  }
1713 
1714  if( $version == $newVersion ) {
1715  $result = $schema;
1716  } else {
1717  $result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion);
1718  }
1719 
1720  if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
1721  fwrite( $fp, $result );
1722  fclose( $fp );
1723  }
1724 
1725  return $result;
1726  }
1727 
1728  // compat for pre-4.3 - jlim
1729  function _file_get_contents($path)
1730  {
1731  if (function_exists('file_get_contents')) return file_get_contents($path);
1732  return join('',file($path));
1733  }
1734 
1751  function ConvertSchemaFile( $filename, $newVersion = NULL, $newFile = NULL ) {
1752 
1753  // grab current version
1754  if( !( $version = $this->SchemaFileVersion( $filename ) ) ) {
1755  return FALSE;
1756  }
1757 
1758  if( !isset ($newVersion) ) {
1759  $newVersion = $this->schemaVersion;
1760  }
1761 
1762  if( $version == $newVersion ) {
1763  $result = _file_get_contents( $filename );
1764 
1765  // remove unicode BOM if present
1766  if( substr( $result, 0, 3 ) == sprintf( '%c%c%c', 239, 187, 191 ) ) {
1767  $result = substr( $result, 3 );
1768  }
1769  } else {
1770  $result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' );
1771  }
1772 
1773  if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
1774  fwrite( $fp, $result );
1775  fclose( $fp );
1776  }
1777 
1778  return $result;
1779  }
1780 
1781  function TransformSchema( $schema, $xsl, $schematype='string' )
1782  {
1783  // Fail if XSLT extension is not available
1784  if( ! function_exists( 'xslt_create' ) ) {
1785  return FALSE;
1786  }
1787 
1788  $xsl_file = dirname( __FILE__ ) . '/xsl/' . $xsl . '.xsl';
1789 
1790  // look for xsl
1791  if( !is_readable( $xsl_file ) ) {
1792  return FALSE;
1793  }
1794 
1795  switch( $schematype )
1796  {
1797  case 'file':
1798  if( !is_readable( $schema ) ) {
1799  return FALSE;
1800  }
1801 
1802  $schema = _file_get_contents( $schema );
1803  break;
1804  case 'string':
1805  default:
1806  if( !is_string( $schema ) ) {
1807  return FALSE;
1808  }
1809  }
1810 
1811  $arguments = array (
1812  '/_xml' => $schema,
1813  '/_xsl' => _file_get_contents( $xsl_file )
1814  );
1815 
1816  // create an XSLT processor
1817  $xh = xslt_create ();
1818 
1819  // set error handler
1820  xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));
1821 
1822  // process the schema
1823  $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
1824 
1825  xslt_free ($xh);
1826 
1827  return $result;
1828  }
1829 
1840  function xslt_error_handler( $parser, $errno, $level, $fields ) {
1841  if( is_array( $fields ) ) {
1842  $msg = array(
1843  'Message Type' => ucfirst( $fields['msgtype'] ),
1844  'Message Code' => $fields['code'],
1845  'Message' => $fields['msg'],
1846  'Error Number' => $errno,
1847  'Level' => $level
1848  );
1849 
1850  switch( $fields['URI'] ) {
1851  case 'arg:/_xml':
1852  $msg['Input'] = 'XML';
1853  break;
1854  case 'arg:/_xsl':
1855  $msg['Input'] = 'XSL';
1856  break;
1857  default:
1858  $msg['Input'] = $fields['URI'];
1859  }
1860 
1861  $msg['Line'] = $fields['line'];
1862  } else {
1863  $msg = array(
1864  'Message Type' => 'Error',
1865  'Error Number' => $errno,
1866  'Level' => $level,
1867  'Fields' => var_export( $fields, TRUE )
1868  );
1869  }
1870 
1871  $error_details = $msg['Message Type'] . ' in XSLT Transformation' . "\n"
1872  . '<table>' . "\n";
1873 
1874  foreach( $msg as $label => $details ) {
1875  $error_details .= '<tr><td><b>' . $label . ': </b></td><td>' . htmlentities( $details ) . '</td></tr>' . "\n";
1876  }
1877 
1878  $error_details .= '</table>';
1879 
1880  trigger_error( $error_details, E_USER_ERROR );
1881  }
1882 
1892  function SchemaFileVersion( $filename ) {
1893  // Open the file
1894  if( !($fp = fopen( $filename, 'r' )) ) {
1895  // die( 'Unable to open file' );
1896  return FALSE;
1897  }
1898 
1899  // Process the file
1900  while( $data = fread( $fp, 4096 ) ) {
1901  if( preg_match( $this->versionRegex, $data, $matches ) ) {
1902  return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1903  }
1904  }
1905 
1906  return FALSE;
1907  }
1908 
1918  function SchemaStringVersion( $xmlstring ) {
1919  if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1920  return FALSE;
1921  }
1922 
1923  if( preg_match( $this->versionRegex, $xmlstring, $matches ) ) {
1924  return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1925  }
1926 
1927  return FALSE;
1928  }
1929 
1940  function ExtractSchema( $data = FALSE ) {
1941  $old_mode = $this->db->SetFetchMode( ADODB_FETCH_NUM );
1942 
1943  $schema = '<?xml version="1.0"?>' . "\n"
1944  . '<schema version="' . $this->schemaVersion . '">' . "\n";
1945 
1946  if( is_array( $tables = $this->db->MetaTables( 'TABLES' ) ) ) {
1947  foreach( $tables as $table ) {
1948  $schema .= ' <table name="' . $table . '">' . "\n";
1949 
1950  // grab details from database
1951  $rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE 1=1' );
1952  $fields = $this->db->MetaColumns( $table );
1953  $indexes = $this->db->MetaIndexes( $table );
1954 
1955  if( is_array( $fields ) ) {
1956  foreach( $fields as $details ) {
1957  $extra = '';
1958  $content = array();
1959 
1960  if( $details->max_length > 0 ) {
1961  $extra .= ' size="' . $details->max_length . '"';
1962  }
1963 
1964  if( $details->primary_key ) {
1965  $content[] = '<KEY/>';
1966  } elseif( $details->not_null ) {
1967  $content[] = '<NOTNULL/>';
1968  }
1969 
1970  if( $details->has_default ) {
1971  $content[] = '<DEFAULT value="' . $details->default_value . '"/>';
1972  }
1973 
1974  if( $details->auto_increment ) {
1975  $content[] = '<AUTOINCREMENT/>';
1976  }
1977 
1978  // this stops the creation of 'R' columns,
1979  // AUTOINCREMENT is used to create auto columns
1980  $details->primary_key = 0;
1981  $type = $rs->MetaType( $details );
1982 
1983  $schema .= ' <field name="' . $details->name . '" type="' . $type . '"' . $extra . '>';
1984 
1985  if( !empty( $content ) ) {
1986  $schema .= "\n " . implode( "\n ", $content ) . "\n ";
1987  }
1988 
1989  $schema .= '</field>' . "\n";
1990  }
1991  }
1992 
1993  if( is_array( $indexes ) ) {
1994  foreach( $indexes as $index => $details ) {
1995  $schema .= ' <index name="' . $index . '">' . "\n";
1996 
1997  if( $details['unique'] ) {
1998  $schema .= ' <UNIQUE/>' . "\n";
1999  }
2000 
2001  foreach( $details['columns'] as $column ) {
2002  $schema .= ' <col>' . $column . '</col>' . "\n";
2003  }
2004 
2005  $schema .= ' </index>' . "\n";
2006  }
2007  }
2008 
2009  if( $data ) {
2010  $rs = $this->db->Execute( 'SELECT * FROM ' . $table );
2011 
2012  if( is_object( $rs ) ) {
2013  $schema .= ' <data>' . "\n";
2014 
2015  while( $row = $rs->FetchRow() ) {
2016  foreach( $row as $key => $val ) {
2017  $row[$key] = htmlentities($val);
2018  }
2019 
2020  $schema .= ' <row><f>' . implode( '</f><f>', $row ) . '</f></row>' . "\n";
2021  }
2022 
2023  $schema .= ' </data>' . "\n";
2024  }
2025  }
2026 
2027  $schema .= ' </table>' . "\n";
2028  }
2029  }
2030 
2031  $this->db->SetFetchMode( $old_mode );
2032 
2033  $schema .= '</schema>';
2034  return $schema;
2035  }
2036 
2047  function SetPrefix( $prefix = '', $underscore = TRUE ) {
2048  switch( TRUE ) {
2049  // clear prefix
2050  case empty( $prefix ):
2051  logMsg( 'Cleared prefix' );
2052  $this->objectPrefix = '';
2053  return TRUE;
2054  // prefix too long
2055  case strlen( $prefix ) > XMLS_PREFIX_MAXLEN:
2056  // prefix contains invalid characters
2057  case !preg_match( '/^[a-z][a-z0-9_]+$/i', $prefix ):
2058  logMsg( 'Invalid prefix: ' . $prefix );
2059  return FALSE;
2060  }
2061 
2062  if( $underscore AND substr( $prefix, -1 ) != '_' ) {
2063  $prefix .= '_';
2064  }
2065 
2066  // prefix valid
2067  logMsg( 'Set prefix: ' . $prefix );
2068  $this->objectPrefix = $prefix;
2069  return TRUE;
2070  }
2071 
2080  function prefix( $name = '' ) {
2081  // if prefix is set
2082  if( !empty( $this->objectPrefix ) ) {
2083  // Prepend the object prefix to the table name
2084  // prepend after quote if used
2085  return preg_replace( '/^(`?)(.+)$/', '$1' . $this->objectPrefix . '$2', $name );
2086  }
2087 
2088  // No prefix set. Use name provided.
2089  return $name;
2090  }
2091 
2100  function supportedPlatform( $platform = NULL ) {
2101  $regex = '/^(\w*\|)*' . $this->db->databaseType . '(\|\w*)*$/';
2102 
2103  if( !isset( $platform ) OR preg_match( $regex, $platform ) ) {
2104  logMsg( "Platform $platform is supported" );
2105  return TRUE;
2106  } else {
2107  logMsg( "Platform $platform is NOT supported" );
2108  return FALSE;
2109  }
2110  }
2111 
2117  function clearSQL() {
2118  $this->sqlArray = array();
2119  }
2120 
2129  function addSQL( $sql = NULL ) {
2130  if( is_array( $sql ) ) {
2131  foreach( $sql as $line ) {
2132  $this->addSQL( $line );
2133  }
2134 
2135  return TRUE;
2136  }
2137 
2138  if( is_string( $sql ) ) {
2139  $this->sqlArray[] = $sql;
2140 
2141  // if executeInline is enabled, and either no errors have occurred or continueOnError is enabled, execute SQL.
2142  if( $this->ExecuteInline() && ( $this->success == 2 || $this->ContinueOnError() ) ) {
2143  $saved = $this->db->debug;
2144  $this->db->debug = $this->debug;
2145  $ok = $this->db->Execute( $sql );
2146  $this->db->debug = $saved;
2147 
2148  if( !$ok ) {
2149  if( $this->debug ) {
2150  ADOConnection::outp( $this->db->ErrorMsg() );
2151  }
2152 
2153  $this->success = 1;
2154  }
2155  }
2156 
2157  return TRUE;
2158  }
2159 
2160  return FALSE;
2161  }
2162 
2171  function getSQL( $format = NULL, $sqlArray = NULL ) {
2172  if( !is_array( $sqlArray ) ) {
2174  }
2175 
2176  if( !is_array( $sqlArray ) ) {
2177  return FALSE;
2178  }
2179 
2180  switch( strtolower( $format ) ) {
2181  case 'string':
2182  case 'text':
2183  return !empty( $sqlArray ) ? implode( ";\n\n", $sqlArray ) . ';' : '';
2184  case'html':
2185  return !empty( $sqlArray ) ? nl2br( htmlentities( implode( ";\n\n", $sqlArray ) . ';' ) ) : '';
2186  }
2187 
2188  return $this->sqlArray;
2189  }
2190 
2197  function Destroy() {
2198  ini_set("magic_quotes_runtime", $this->mgq );
2199  #set_magic_quotes_runtime( $this->mgq );
2200  }
2201 }
2202 
2208 function logMsg( $msg, $title = NULL, $force = FALSE ) {
2209  if( XMLS_DEBUG or $force ) {
2210  echo '<pre>';
2211 
2212  if( isset( $title ) ) {
2213  echo '<h3>' . htmlentities( $title ) . '</h3>';
2214  }
2215 
2216  if( is_object( $this ) ) {
2217  echo '[' . get_class( $this ) . '] ';
2218  }
2219 
2220  print_r( $msg );
2221 
2222  echo '</pre>';
2223  }
2224 }
dbObject\destroy
destroy()
Definition: adodb-xmlschema.inc.php:159
adoSchema\SetPrefix
SetPrefix( $prefix='', $underscore=TRUE)
Definition: adodb-xmlschema.inc.php:2047
adoSchema\$dict
$dict
Definition: adodb-xmlschema.inc.php:1237
dbIndex\$opts
$opts
Definition: adodb-xmlschema.inc.php:625
dbQuerySet\prefixQuery
prefixQuery( $regex, $query, $prefix=NULL)
Definition: adodb-xmlschema.inc.php:1178
dbQuerySet\_tag_close
_tag_close(&$parser, $tag)
Definition: adodb-xmlschema.inc.php:1057
dbTable\addTableOpt
addTableOpt( $opt)
Definition: adodb-xmlschema.inc.php:466
dbTable\$name
$name
Definition: adodb-xmlschema.inc.php:210
dbObject\supportedPlatform
supportedPlatform( $platform=NULL)
Definition: adodb-xmlschema.inc.php:169
adoSchema\ContinueOnError
ContinueOnError( $mode=NULL)
Definition: adodb-xmlschema.inc.php:1400
dbIndex\drop
drop()
Definition: adodb-xmlschema.inc.php:763
dbQuerySet\__construct
__construct(&$parent, $attributes=NULL)
Definition: adodb-xmlschema.inc.php:989
dbIndex\$drop
$drop
Definition: adodb-xmlschema.inc.php:636
dbIndex\$name
$name
Definition: adodb-xmlschema.inc.php:620
dbTable\$opts
$opts
Definition: adodb-xmlschema.inc.php:225
$rs
if(isset($_REQUEST['nrows'])) else $rs
Definition: server.php:94
dbTable\addField
addField( $name, $type, $size=NULL, $opts=NULL)
Definition: adodb-xmlschema.inc.php:414
dbObject\create
create(&$xmls)
Definition: adodb-xmlschema.inc.php:152
$sql
$sql
Definition: server.php:84
adoSchema\SaveSQL
SaveSQL( $filename='./schema.sql')
Definition: adodb-xmlschema.inc.php:1610
dbData\_tag_close
_tag_close(&$parser, $tag)
Definition: adodb-xmlschema.inc.php:840
adoSchema\$mgq
$mgq
Definition: adodb-xmlschema.inc.php:1261
dbTable\$drop_table
$drop_table
Definition: adodb-xmlschema.inc.php:236
upgrade
upgrade()
Definition: installcli.php:150
adoSchema\ExecuteInline
ExecuteInline( $mode=NULL)
Definition: adodb-xmlschema.inc.php:1379
dbQuerySet\buildQuery
buildQuery( $sql=NULL)
Definition: adodb-xmlschema.inc.php:1103
adoSchema\ExtractSchema
ExtractSchema( $data=FALSE)
Definition: adodb-xmlschema.inc.php:1940
dbObject\$currentElement
$currentElement
Definition: adodb-xmlschema.inc.php:116
dbQuerySet\discardQuery
discardQuery()
Definition: adodb-xmlschema.inc.php:1091
dbIndex\addIndexOpt
addIndexOpt( $opt)
Definition: adodb-xmlschema.inc.php:732
dbData\create
create(&$xmls)
Definition: adodb-xmlschema.inc.php:891
adoSchema\SetUpgradeMethod
SetUpgradeMethod( $method='')
Definition: adodb-xmlschema.inc.php:1337
adoSchema\$success
$success
Definition: adodb-xmlschema.inc.php:1284
dbQuerySet\newQuery
newQuery()
Definition: adodb-xmlschema.inc.php:1080
dbData\_tag_cdata
_tag_cdata(&$parser, $cdata)
Definition: adodb-xmlschema.inc.php:824
dbIndex\addField
addField( $name)
Definition: adodb-xmlschema.inc.php:719
dbObject\_tag_open
_tag_open(&$parser, $tag, $attributes)
Definition: adodb-xmlschema.inc.php:130
adoSchema\ExecuteSchema
ExecuteSchema( $sqlArray=NULL, $continueOnErr=NULL)
Definition: adodb-xmlschema.inc.php:1569
adoSchema\ParseSchema
ParseSchema( $filename, $returnSchema=FALSE)
Definition: adodb-xmlschema.inc.php:1419
adoSchema
Definition: adodb-xmlschema.inc.php:1219
dbTable\addIndex
addIndex( $attributes)
Definition: adodb-xmlschema.inc.php:366
dbQuerySet\create
create(&$xmls)
Definition: adodb-xmlschema.inc.php:1136
dbTable\addFieldOpt
addFieldOpt( $field, $opt, $value=NULL)
Definition: adodb-xmlschema.inc.php:448
adoSchema\prefix
prefix( $name='')
Definition: adodb-xmlschema.inc.php:2080
adoSchema\clearSQL
clearSQL()
Definition: adodb-xmlschema.inc.php:2117
logMsg
logMsg( $msg, $title=NULL, $force=FALSE)
Definition: adodb-xmlschema.inc.php:2208
dbTable\$drop_field
$drop_field
Definition: adodb-xmlschema.inc.php:242
adoSchema\PrintSQL
PrintSQL( $format='NONE')
Definition: adodb-xmlschema.inc.php:1596
adoSchema\xslt_error_handler
xslt_error_handler( $parser, $errno, $level, $fields)
Definition: adodb-xmlschema.inc.php:1840
dbData\__construct
__construct(&$parent, $attributes=NULL)
Definition: adodb-xmlschema.inc.php:790
adoSchema\$schemaVersion
$schemaVersion
Definition: adodb-xmlschema.inc.php:1279
adoSchema\$versionRegex
$versionRegex
Definition: adodb-xmlschema.inc.php:1273
dbData\addData
addData( $cdata)
Definition: adodb-xmlschema.inc.php:873
adoSchema\SchemaStringVersion
SchemaStringVersion( $xmlstring)
Definition: adodb-xmlschema.inc.php:1918
$type
$type
Definition: dcm.php:17
adoSchema\SchemaFileVersion
SchemaFileVersion( $filename)
Definition: adodb-xmlschema.inc.php:1892
dbObject\_tag_cdata
_tag_cdata(&$parser, $cdata)
Definition: adodb-xmlschema.inc.php:139
adoSchema\addSQL
addSQL( $sql=NULL)
Definition: adodb-xmlschema.inc.php:2129
dbTable\_tag_open
_tag_open(&$parser, $tag, $attributes)
Definition: adodb-xmlschema.inc.php:261
dbTable\$current_field
$current_field
Definition: adodb-xmlschema.inc.php:230
dbQuerySet\$prefixKey
$prefixKey
Definition: adodb-xmlschema.inc.php:976
dbQuerySet
Definition: adodb-xmlschema.inc.php:961
adoSchema\Destroy
Destroy()
Definition: adodb-xmlschema.inc.php:2197
adoSchema\ConvertSchemaFile
ConvertSchemaFile( $filename, $newVersion=NULL, $newFile=NULL)
Definition: adodb-xmlschema.inc.php:1751
dbQuerySet\$query
$query
Definition: adodb-xmlschema.inc.php:971
dbData
Definition: adodb-xmlschema.inc.php:776
dbQuerySet\_tag_open
_tag_open(&$parser, $tag, $attributes)
Definition: adodb-xmlschema.inc.php:1019
adoSchema\_tag_close
_tag_close(&$parser, $tag)
Definition: adodb-xmlschema.inc.php:1683
adoSchema\_tag_open
_tag_open(&$parser, $tag, $attributes)
Definition: adodb-xmlschema.inc.php:1651
adoSchema\$db
$db
Definition: adodb-xmlschema.inc.php:1231
dbObject\prefix
prefix( $name='')
Definition: adodb-xmlschema.inc.php:179
adoSchema\$sqlArray
$sqlArray
Definition: adodb-xmlschema.inc.php:1225
dbIndex\_tag_cdata
_tag_cdata(&$parser, $cdata)
Definition: adodb-xmlschema.inc.php:687
dbObject\_tag_close
_tag_close(&$parser, $tag)
Definition: adodb-xmlschema.inc.php:148
adoSchema\__construct
__construct( $db)
Definition: adodb-xmlschema.inc.php:1305
dbObject
Definition: adodb-xmlschema.inc.php:106
dbIndex\$columns
$columns
Definition: adodb-xmlschema.inc.php:630
dbTable\$fields
$fields
Definition: adodb-xmlschema.inc.php:215
dbTable\__construct
__construct(&$parent, $attributes=NULL)
Definition: adodb-xmlschema.inc.php:250
dbQuerySet\_tag_cdata
_tag_cdata(&$parser, $cdata)
Definition: adodb-xmlschema.inc.php:1041
dbQuerySet\$prefixMethod
$prefixMethod
Definition: adodb-xmlschema.inc.php:981
dbIndex\create
create(&$xmls)
Definition: adodb-xmlschema.inc.php:745
adoSchema\$executeInline
$executeInline
Definition: adodb-xmlschema.inc.php:1289
adoSchema\_file_get_contents
_file_get_contents($path)
Definition: adodb-xmlschema.inc.php:1729
adoSchema\TransformSchema
TransformSchema( $schema, $xsl, $schematype='string')
Definition: adodb-xmlschema.inc.php:1781
dbObject\__construct
__construct(&$parent, $attributes=NULL)
Definition: adodb-xmlschema.inc.php:121
dbData\$data
$data
Definition: adodb-xmlschema.inc.php:778
adoSchema\$debug
$debug
Definition: adodb-xmlschema.inc.php:1267
adoSchema\_tag_cdata
_tag_cdata(&$parser, $cdata)
Definition: adodb-xmlschema.inc.php:1674
adoSchema\RemoveSchemaString
RemoveSchemaString( $schema, $returnSchema=FALSE)
Definition: adodb-xmlschema.inc.php:1546
adoSchema\$objectPrefix
$objectPrefix
Definition: adodb-xmlschema.inc.php:1255
dbTable\create
create(&$xmls)
Definition: adodb-xmlschema.inc.php:480
dbIndex\_tag_close
_tag_close(&$parser, $tag)
Definition: adodb-xmlschema.inc.php:703
dbTable\drop
drop()
Definition: adodb-xmlschema.inc.php:589
adoSchema\RemoveSchema
RemoveSchema( $filename, $returnSchema=FALSE)
Definition: adodb-xmlschema.inc.php:1531
dbTable\addData
addData( $attributes)
Definition: adodb-xmlschema.inc.php:378
_file_get_contents
_file_get_contents($file)
Definition: adodb-xmlschema.inc.php:21
dbTable\_tag_cdata
_tag_cdata(&$parser, $cdata)
Definition: adodb-xmlschema.inc.php:320
dbTable
Definition: adodb-xmlschema.inc.php:205
dbObject\$parent
$parent
Definition: adodb-xmlschema.inc.php:111
adoSchema\ParseSchemaString
ParseSchemaString( $xmlstring, $returnSchema=FALSE)
Definition: adodb-xmlschema.inc.php:1488
adoSchema\getSQL
getSQL( $format=NULL, $sqlArray=NULL)
Definition: adodb-xmlschema.inc.php:2171
dbTable\$indexes
$indexes
Definition: adodb-xmlschema.inc.php:220
dbData\addField
addField( $attributes)
Definition: adodb-xmlschema.inc.php:856
dbTable\_tag_close
_tag_close(&$parser, $tag)
Definition: adodb-xmlschema.inc.php:344
adoSchema\ParseSchemaFile
ParseSchemaFile( $filename, $returnSchema=FALSE)
Definition: adodb-xmlschema.inc.php:1436
adoSchema\create_parser
create_parser()
Definition: adodb-xmlschema.inc.php:1634
dbObject\FieldID
FieldID( $field)
Definition: adodb-xmlschema.inc.php:189
adoSchema\supportedPlatform
supportedPlatform( $platform=NULL)
Definition: adodb-xmlschema.inc.php:2100
adoSchema\$continueOnError
$continueOnError
Definition: adodb-xmlschema.inc.php:1294
E_USER_ERROR
if(!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE' E_USER_ERROR
Definition: adodb-errorhandler.inc.php:18
$version
$version
Definition: main.inc.php:22
dbData\_tag_open
_tag_open(&$parser, $tag, $attributes)
Definition: adodb-xmlschema.inc.php:802
dbData\$row
$row
Definition: adodb-xmlschema.inc.php:780
dbQuerySet\$queries
$queries
Definition: adodb-xmlschema.inc.php:966
dbIndex\__construct
__construct(&$parent, $attributes=NULL)
Definition: adodb-xmlschema.inc.php:646
adoSchema\$upgrade
$upgrade
Definition: adodb-xmlschema.inc.php:1249
adoSchema\ConvertSchemaString
ConvertSchemaString( $schema, $newVersion=NULL, $newFile=NULL)
Definition: adodb-xmlschema.inc.php:1703
dbQuerySet\addQuery
addQuery()
Definition: adodb-xmlschema.inc.php:1118
dbIndex
Definition: adodb-xmlschema.inc.php:615
adoSchema\$currentElement
$currentElement
Definition: adodb-xmlschema.inc.php:1243
dbIndex\_tag_open
_tag_open(&$parser, $tag, $attributes)
Definition: adodb-xmlschema.inc.php:660