23 if (function_exists(
'file_get_contents'))
return file_get_contents($file);
25 $f = fopen($file,
'r');
29 while ($s = fread($f,100000)) $t .= $s;
38 if( !defined(
'XMLS_DEBUG' ) ) {
39 define(
'XMLS_DEBUG', FALSE );
45 if( !defined(
'XMLS_PREFIX' ) ) {
46 define(
'XMLS_PREFIX',
'%%P' );
52 if( !defined(
'XMLS_PREFIX_MAXLEN' ) ) {
53 define(
'XMLS_PREFIX_MAXLEN', 10 );
59 if( !defined(
'XMLS_EXECUTE_INLINE' ) ) {
60 define(
'XMLS_EXECUTE_INLINE', FALSE );
66 if( !defined(
'XMLS_CONTINUE_ON_ERROR' ) ) {
67 define(
'XMLS_CONTINUE_ON_ERROR', FALSE );
73 if( !defined(
'XMLS_SCHEMA_VERSION' ) ) {
74 define(
'XMLS_SCHEMA_VERSION',
'0.2' );
80 if( !defined(
'XMLS_DEFAULT_SCHEMA_VERSION' ) ) {
81 define(
'XMLS_DEFAULT_SCHEMA_VERSION',
'0.1' );
87 if( !defined(
'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
88 define(
'XMLS_DEFAULT_UPGRADE_METHOD',
'ALTER' );
94 if( !defined(
'_ADODB_LAYER' ) ) {
95 require(
'adodb.inc.php' );
96 require(
'adodb-datadict.inc.php' );
121 function dbObject( &$parent, $attributes = NULL ) {
171 return is_object( $this->parent ) ? $this->parent->supportedPlatform( $platform ) : TRUE;
181 return is_object( $this->parent ) ? $this->parent->prefix( $name ) : $name;
191 return strtoupper( preg_replace(
'/^`(.+)`$/',
'$1', $field ) );
216 var $fields = array();
221 var $indexes = array();
243 var $drop_field = array();
253 $this->name = $this->
prefix($attributes[
'NAME']);
263 $this->currentElement = strtoupper( $tag );
265 switch( $this->currentElement ) {
267 if( !isset( $attributes[
'PLATFORM'] ) OR $this->
supportedPlatform( $attributes[
'PLATFORM'] ) ) {
268 xml_set_object( $parser, $this->addIndex( $attributes ) );
272 if( !isset( $attributes[
'PLATFORM'] ) OR $this->
supportedPlatform( $attributes[
'PLATFORM'] ) ) {
273 xml_set_object( $parser, $this->addData( $attributes ) );
281 $fieldName = $attributes[
'NAME'];
282 $fieldType = $attributes[
'TYPE'];
283 $fieldSize = isset( $attributes[
'SIZE'] ) ? $attributes[
'SIZE'] : NULL;
284 $fieldOpts = isset( $attributes[
'OPTS'] ) ? $attributes[
'OPTS'] : NULL;
286 $this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
290 case 'AUTOINCREMENT':
292 $this->addFieldOpt( $this->current_field, $this->currentElement );
298 if( $attributes[
'VALUE'] ==
'' ) {
299 $attributes[
'VALUE'] =
" '' ";
302 $this->addFieldOpt( $this->current_field, $this->currentElement, $attributes[
'VALUE'] );
307 $this->addFieldOpt( $this->current_field, $this->currentElement );
320 switch( $this->currentElement ) {
323 if( isset( $this->current_field ) ) {
324 $this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
326 $this->addTableOpt( $cdata );
331 $this->addTableOpt( $cdata );
344 $this->currentElement =
'';
346 switch( strtoupper( $tag ) ) {
348 $this->parent->addSQL( $this->
create( $this->parent ) );
349 xml_set_object( $parser, $this->parent );
353 unset($this->current_field);
366 $name = strtoupper( $attributes[
'NAME'] );
367 $this->indexes[$name] =
new dbIndex( $this, $attributes );
368 return $this->indexes[$name];
378 if( !isset( $this->data ) ) {
379 $this->data =
new dbData( $this, $attributes );
413 function addField( $name, $type, $size = NULL, $opts = NULL ) {
414 $field_id = $this->
FieldID( $name );
417 $this->current_field = $field_id;
420 $this->fields[$field_id][
'NAME'] = $name;
423 $this->fields[$field_id][
'TYPE'] = $type;
426 if( isset( $size ) ) {
427 $this->fields[$field_id][
'SIZE'] = $size;
431 if( isset( $opts ) ) {
432 $this->fields[$field_id][
'OPTS'][] = $opts;
448 if( !isset( $value ) ) {
449 $this->fields[$this->
FieldID( $field )][
'OPTS'][] = $opt;
452 $this->fields[$this->
FieldID( $field )][
'OPTS'][] = array( $opt => $value );
466 if(isset($this->currentPlatform)) {
467 $this->opts[$this->parent->db->databaseType] = $opt;
483 if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) {
484 foreach( $legacy_indexes as $index => $index_details ) {
485 $sql[] = $xmls->dict->DropIndexSQL( $index, $this->name );
490 foreach( $this->drop_field as $field ) {
491 unset( $this->fields[$field] );
495 if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) {
497 if( $this->drop_table ) {
498 $sql[] = $xmls->dict->DropTableSQL( $this->name );
504 foreach( $legacy_fields as $field_id => $field ) {
505 if( !isset( $this->fields[$field_id] ) ) {
506 $sql[] = $xmls->dict->DropColumnSQL( $this->name,
'`'.$field->name.
'`' );
511 if( $this->drop_table ) {
515 $legacy_fields = array();
521 foreach( $this->fields as $field_id => $finfo ) {
523 if( !isset( $finfo[
'SIZE'] ) ) {
528 $fldarray[$field_id] = array(
529 'NAME' => $finfo[
'NAME'],
530 'TYPE' => $finfo[
'TYPE'],
531 'SIZE' => $finfo[
'SIZE']
535 if( isset( $finfo[
'OPTS'] ) ) {
536 foreach( $finfo[
'OPTS'] as $opt ) {
538 if( is_array( $opt ) ) {
540 $value = $opt[key( $opt )];
541 @$fldarray[$field_id][$key] .= $value;
544 $fldarray[$field_id][$opt] = $opt;
550 if( empty( $legacy_fields ) ) {
552 $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
553 logMsg( end(
$sql ),
'Generated CreateTableSQL' );
556 logMsg(
"Upgrading {$this->name} using '{$xmls->upgrade}'" );
557 switch( $xmls->upgrade ) {
560 logMsg(
'Generated ChangeTableSQL (ALTERing table)' );
561 $sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts );
564 logMsg(
'Doing upgrade REPLACE (testing)' );
565 $sql[] = $xmls->dict->DropTableSQL( $this->name );
566 $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
574 foreach( $this->indexes as $index ) {
575 $sql[] = $index->create( $xmls );
578 if( isset( $this->data ) ) {
579 $sql[] = $this->data->create( $xmls );
589 if( isset( $this->current_field ) ) {
591 logMsg(
"Dropping field '{$this->current_field}' from table '{$this->name}'" );
593 $this->drop_field[$this->current_field] = $this->current_field;
596 logMsg(
"Dropping table '{$this->name}'" );
598 $this->drop_table = TRUE;
629 var $columns = array();
648 $this->name = $this->
prefix ($attributes[
'NAME']);
660 $this->currentElement = strtoupper( $tag );
662 switch( $this->currentElement ) {
672 $this->addIndexOpt( $this->currentElement );
687 switch( $this->currentElement ) {
690 $this->addField( $cdata );
703 $this->currentElement =
'';
705 switch( strtoupper( $tag ) ) {
707 xml_set_object( $parser, $this->parent );
719 $this->columns[$this->
FieldID( $name )] = $name;
722 return $this->columns;
732 $this->opts[] = $opt;
750 foreach( $this->columns as $id => $col ) {
751 if( !isset( $this->parent->fields[$id] ) ) {
752 unset( $this->columns[$id] );
756 return $xmls->dict->CreateIndexSQL( $this->name, $this->parent->name, $this->columns, $this->opts );
802 $this->currentElement = strtoupper( $tag );
804 switch( $this->currentElement ) {
806 $this->row = count( $this->data );
807 $this->data[$this->row] = array();
810 $this->addField($attributes);
824 switch( $this->currentElement ) {
827 $this->addData( $cdata );
840 $this->currentElement =
'';
842 switch( strtoupper( $tag ) ) {
844 xml_set_object( $parser, $this->parent );
856 if( isset( $attributes[
'NAME'] ) ) {
857 $name = $attributes[
'NAME'];
859 $name = count($this->data[$this->row]);
863 $this->current_field = $this->
FieldID( $name );
873 if( !isset( $this->data[$this->row] ) ) {
874 $this->data[$this->row] = array();
877 if( !isset( $this->data[$this->row][$this->current_field] ) ) {
878 $this->data[$this->row][$this->current_field] =
'';
881 $this->data[$this->row][$this->current_field] .= $cdata;
891 $table = $xmls->dict->TableName($this->parent->name);
892 $table_field_count = count($this->parent->fields);
896 foreach( $this->data as $row ) {
897 $table_fields = $this->parent->fields;
900 foreach( $row as $field_id => $field_data ) {
901 if( !array_key_exists( $field_id, $table_fields ) ) {
902 if( is_numeric( $field_id ) ) {
903 $field_id = reset( array_keys( $table_fields ) );
909 $name = $table_fields[$field_id][
'NAME'];
911 switch( $table_fields[$field_id][
'TYPE'] ) {
916 $fields[$name] = $xmls->db->qstr( $field_data );
923 $fields[$name] = intval($field_data);
926 $fields[$name] = $field_data;
929 unset($table_fields[$field_id]);
933 if( empty( $fields ) ) {
938 if( count( $fields ) < $table_field_count ) {
939 foreach( $table_fields as $field ) {
940 if (isset( $field[
'OPTS'] ))
941 if( ( in_array(
'NOTNULL', $field[
'OPTS'] ) || in_array(
'KEY', $field[
'OPTS'] ) ) && !in_array(
'AUTOINCREMENT', $field[
'OPTS'] ) ) {
947 $sql[] =
'INSERT INTO '. $table .
' ('. implode(
',', array_keys( $fields ) ) .
') VALUES ('. implode(
',', $fields ) .
')';
965 var $queries = array();
980 var $prefixMethod =
'AUTO';
992 if( isset( $attributes[
'KEY'] ) ) {
993 $this->prefixKey = $attributes[
'KEY'];
996 $prefixMethod = isset( $attributes[
'PREFIXMETHOD'] ) ? strtoupper( trim( $attributes[
'PREFIXMETHOD'] ) ) :
'';
999 switch( $prefixMethod ) {
1001 $this->prefixMethod =
'AUTO';
1004 $this->prefixMethod =
'MANUAL';
1007 $this->prefixMethod =
'NONE';
1019 $this->currentElement = strtoupper( $tag );
1021 switch( $this->currentElement ) {
1026 if( !isset( $attributes[
'PLATFORM'] ) OR $this->
supportedPlatform( $attributes[
'PLATFORM'] ) ) {
1029 $this->discardQuery();
1041 switch( $this->currentElement ) {
1044 $this->buildQuery( $cdata );
1057 $this->currentElement =
'';
1059 switch( strtoupper( $tag ) ) {
1065 $this->parent->addSQL( $this->
create( $this->parent ) );
1066 xml_set_object( $parser, $this->parent );
1091 unset( $this->query );
1103 if( !isset( $this->query ) OR empty(
$sql ) ) {
1107 $this->query .=
$sql;
1109 return $this->query;
1118 if( !isset( $this->query ) ) {
1122 $this->queries[] = $return = trim($this->query);
1124 unset( $this->query );
1136 foreach( $this->queries as $id => $query ) {
1137 switch( $this->prefixMethod ) {
1143 $query = $this->prefixQuery(
'/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
1144 $query = $this->prefixQuery(
'/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
1145 $query = $this->prefixQuery(
'/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
1148 #$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data ); 1153 if( isset( $this->prefixKey ) AND( $this->prefixKey !==
'' ) ) {
1155 $query = str_replace( $this->prefixKey, $xmls->objectPrefix, $query );
1158 $query = str_replace( XMLS_PREFIX , $xmls->objectPrefix, $query );
1162 $this->queries[$id] = trim( $query );
1166 return $this->queries;
1178 if( !isset( $prefix ) ) {
1182 if( preg_match( $regex, $query, $match ) ) {
1183 $preamble = $match[1];
1184 $postamble = $match[5];
1185 $objectList = explode(
',', $match[3] );
1190 foreach( $objectList as $object ) {
1191 if( $prefixedList !==
'' ) {
1192 $prefixedList .=
', ';
1195 $prefixedList .= $prefix . trim( $object );
1198 $query = $preamble .
' ' . $prefixedList .
' ' . $postamble;
1254 var $objectPrefix =
'';
1272 var $versionRegex =
'/<schema.*?( version="([^"]*)")?.*?>/';
1306 $this->mgq = get_magic_quotes_runtime();
1307 ini_set(
"magic_quotes_runtime", 0);
1308 #set_magic_quotes_runtime(0); 1311 $this->
debug = $this->db->debug;
1312 $this->dict = NewDataDictionary( $this->db );
1313 $this->sqlArray = array();
1314 $this->schemaVersion = XMLS_SCHEMA_VERSION;
1315 $this->executeInline( XMLS_EXECUTE_INLINE );
1316 $this->continueOnError( XMLS_CONTINUE_ON_ERROR );
1317 $this->setUpgradeMethod();
1337 if( !is_string( $method ) ) {
1341 $method = strtoupper( $method );
1346 $this->upgrade = $method;
1349 $this->upgrade = $method;
1352 $this->upgrade =
'ALTER';
1355 $this->upgrade =
'NONE';
1359 $this->upgrade = XMLS_DEFAULT_UPGRADE_METHOD;
1362 return $this->upgrade;
1379 if( is_bool( $mode ) ) {
1380 $this->executeInline = $mode;
1383 return $this->executeInline;
1400 if( is_bool( $mode ) ) {
1401 $this->continueOnError = $mode;
1404 return $this->continueOnError;
1419 return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1437 if( !($fp = fopen( $filename,
'r' )) ) {
1443 if( $this->SchemaFileVersion( $filename ) != $this->schemaVersion ) {
1447 if ( $returnSchema )
1450 while( $data = fread( $fp, 100000 ) ) {
1451 $xmlstring .= $data;
1458 $xmlParser = $this->create_parser();
1460 $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
1463 while( $data = fread( $fp, 4096 ) ) {
1464 if( !xml_parse( $xmlParser, $data, feof( $fp ) ) ) {
1466 "XML error: %s at line %d",
1467 xml_error_string( xml_get_error_code( $xmlParser) ),
1468 xml_get_current_line_number( $xmlParser)
1473 libxml_disable_entity_loader($previousValueOfEntityLoader);
1474 xml_parser_free( $xmlParser );
1476 return $this->sqlArray;
1491 if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1496 if( $this->SchemaStringVersion( $xmlstring ) != $this->schemaVersion ) {
1500 if ( $returnSchema )
1507 $xmlParser = $this->create_parser();
1509 $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
1511 if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) {
1513 "XML error: %s at line %d",
1514 xml_error_string( xml_get_error_code( $xmlParser) ),
1515 xml_get_current_line_number( $xmlParser)
1519 libxml_disable_entity_loader($previousValueOfEntityLoader);
1520 xml_parser_free( $xmlParser );
1522 return $this->sqlArray;
1537 return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
1554 if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
1558 return $this->ParseSchemaString( $this->TransformSchema( $schema,
'remove-' . $version), $returnSchema );
1575 if( !is_bool( $continueOnErr ) ) {
1576 $continueOnErr = $this->ContinueOnError();
1579 if( !isset( $sqlArray ) ) {
1580 $sqlArray = $this->sqlArray;
1583 if( !is_array( $sqlArray ) ) {
1586 $this->success = $this->dict->ExecuteSQLArray( $sqlArray, $continueOnErr );
1589 return $this->success;
1603 return $this->getSQL( $format, $sqlArray );
1617 if( !isset( $sqlArray ) ) {
1618 $sqlArray = $this->sqlArray;
1620 if( !isset( $sqlArray ) ) {
1624 $fp = fopen( $filename,
"w" );
1626 foreach( $sqlArray as $key => $query ) {
1627 fwrite( $fp, $query .
";\n" );
1641 $xmlParser = xml_parser_create();
1642 xml_set_object( $xmlParser, $this );
1645 xml_set_element_handler( $xmlParser,
'_tag_open',
'_tag_close' );
1646 xml_set_character_data_handler( $xmlParser,
'_tag_cdata' );
1657 switch( strtoupper( $tag ) ) {
1659 $this->obj =
new dbTable( $this, $attributes );
1660 xml_set_object( $parser, $this->obj );
1663 if( !isset( $attributes[
'PLATFORM'] ) OR $this->
supportedPlatform( $attributes[
'PLATFORM'] ) ) {
1664 $this->obj =
new dbQuerySet( $this, $attributes );
1665 xml_set_object( $parser, $this->obj );
1711 if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
1715 if( !isset ($newVersion) ) {
1716 $newVersion = $this->schemaVersion;
1719 if( $version == $newVersion ) {
1722 $result = $this->TransformSchema( $schema,
'convert-' . $version .
'-' . $newVersion);
1725 if( is_string(
$result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile,
'w' ) ) ) {
1736 if (function_exists(
'file_get_contents'))
return file_get_contents($path);
1737 return join(
'',file($path));
1759 if( !( $version = $this->SchemaFileVersion( $filename ) ) ) {
1763 if( !isset ($newVersion) ) {
1764 $newVersion = $this->schemaVersion;
1767 if( $version == $newVersion ) {
1771 if( substr(
$result, 0, 3 ) == sprintf(
'%c%c%c', 239, 187, 191 ) ) {
1775 $result = $this->TransformSchema( $filename,
'convert-' . $version .
'-' . $newVersion,
'file' );
1778 if( is_string(
$result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile,
'w' ) ) ) {
1789 if( ! function_exists(
'xslt_create' ) ) {
1793 $xsl_file = dirname( __FILE__ ) .
'/xsl/' . $xsl .
'.xsl';
1796 if( !is_readable( $xsl_file ) ) {
1800 switch( $schematype )
1803 if( !is_readable( $schema ) ) {
1811 if( !is_string( $schema ) ) {
1816 $arguments = array (
1822 $xh = xslt_create ();
1825 xslt_set_error_handler ($xh, array (&$this,
'xslt_error_handler'));
1828 $result = xslt_process ($xh,
'arg:/_xml',
'arg:/_xsl', NULL, $arguments);
1846 if( is_array( $fields ) ) {
1848 'Message Type' => ucfirst( $fields[
'msgtype'] ),
1849 'Message Code' => $fields[
'code'],
1850 'Message' => $fields[
'msg'],
1851 'Error Number' => $errno,
1855 switch( $fields[
'URI'] ) {
1857 $msg[
'Input'] =
'XML';
1860 $msg[
'Input'] =
'XSL';
1863 $msg[
'Input'] = $fields[
'URI'];
1866 $msg[
'Line'] = $fields[
'line'];
1869 'Message Type' =>
'Error',
1870 'Error Number' => $errno,
1872 'Fields' => var_export( $fields, TRUE )
1876 $error_details = $msg[
'Message Type'] .
' in XSLT Transformation' .
"\n" 1879 foreach( $msg as $label => $details ) {
1880 $error_details .=
'<tr><td><b>' . $label .
': </b></td><td>' . htmlentities( $details ) .
'</td></tr>' .
"\n";
1883 $error_details .=
'</table>';
1899 if( !($fp = fopen( $filename,
'r' )) ) {
1905 while( $data = fread( $fp, 4096 ) ) {
1906 if( preg_match( $this->versionRegex, $data, $matches ) ) {
1907 return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1924 if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
1928 if( preg_match( $this->versionRegex, $xmlstring, $matches ) ) {
1929 return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
1946 $old_mode = $this->db->SetFetchMode( ADODB_FETCH_NUM );
1948 $schema =
'<?xml version="1.0"?>' .
"\n" 1949 .
'<schema version="' . $this->schemaVersion .
'">' .
"\n";
1951 if( is_array( $tables = $this->db->MetaTables(
'TABLES' ) ) ) {
1952 foreach( $tables as $table ) {
1953 $schema .=
' <table name="' . $table .
'">' .
"\n";
1956 $rs = $this->db->Execute(
'SELECT * FROM ' . $table .
' WHERE 1=1' );
1957 $fields = $this->db->MetaColumns( $table );
1958 $indexes = $this->db->MetaIndexes( $table );
1960 if( is_array( $fields ) ) {
1961 foreach( $fields as $details ) {
1965 if( $details->max_length > 0 ) {
1966 $extra .=
' size="' . $details->max_length .
'"';
1969 if( $details->primary_key ) {
1970 $content[] =
'<KEY/>';
1971 } elseif( $details->not_null ) {
1972 $content[] =
'<NOTNULL/>';
1975 if( $details->has_default ) {
1976 $content[] =
'<DEFAULT value="' . $details->default_value .
'"/>';
1979 if( $details->auto_increment ) {
1980 $content[] =
'<AUTOINCREMENT/>';
1985 $details->primary_key = 0;
1986 $type =
$rs->MetaType( $details );
1988 $schema .=
' <field name="' . $details->name .
'" type="' . $type .
'"' . $extra .
'>';
1990 if( !empty( $content ) ) {
1991 $schema .=
"\n " . implode(
"\n ", $content ) .
"\n ";
1994 $schema .=
'</field>' .
"\n";
1998 if( is_array( $indexes ) ) {
1999 foreach( $indexes as $index => $details ) {
2000 $schema .=
' <index name="' . $index .
'">' .
"\n";
2002 if( $details[
'unique'] ) {
2003 $schema .=
' <UNIQUE/>' .
"\n";
2006 foreach( $details[
'columns'] as $column ) {
2007 $schema .=
' <col>' . $column .
'</col>' .
"\n";
2010 $schema .=
' </index>' .
"\n";
2015 $rs = $this->db->Execute(
'SELECT * FROM ' . $table );
2017 if( is_object(
$rs ) ) {
2018 $schema .=
' <data>' .
"\n";
2020 while( $row =
$rs->FetchRow() ) {
2021 foreach( $row as $key => $val ) {
2022 $row[$key] = htmlentities($val);
2025 $schema .=
' <row><f>' . implode(
'</f><f>', $row ) .
'</f></row>' .
"\n";
2028 $schema .=
' </data>' .
"\n";
2032 $schema .=
' </table>' .
"\n";
2036 $this->db->SetFetchMode( $old_mode );
2038 $schema .=
'</schema>';
2055 case empty( $prefix ):
2056 logMsg(
'Cleared prefix' );
2057 $this->objectPrefix =
'';
2060 case strlen( $prefix ) > XMLS_PREFIX_MAXLEN:
2062 case !preg_match(
'/^[a-z][a-z0-9_]+$/i', $prefix ):
2063 logMsg(
'Invalid prefix: ' . $prefix );
2067 if( $underscore AND substr( $prefix, -1 ) !=
'_' ) {
2072 logMsg(
'Set prefix: ' . $prefix );
2073 $this->objectPrefix = $prefix;
2087 if( !empty( $this->objectPrefix ) ) {
2090 return preg_replace(
'/^(`?)(.+)$/',
'$1' . $this->objectPrefix .
'$2', $name );
2106 $regex =
'/^(\w*\|)*' . $this->db->databaseType .
'(\|\w*)*$/';
2108 if( !isset( $platform ) OR preg_match( $regex, $platform ) ) {
2109 logMsg(
"Platform $platform is supported" );
2112 logMsg(
"Platform $platform is NOT supported" );
2123 $this->sqlArray = array();
2135 if( is_array(
$sql ) ) {
2136 foreach(
$sql as $line ) {
2137 $this->addSQL( $line );
2143 if( is_string(
$sql ) ) {
2144 $this->sqlArray[] =
$sql;
2147 if( $this->ExecuteInline() && ( $this->success == 2 || $this->ContinueOnError() ) ) {
2148 $saved = $this->db->debug;
2149 $this->db->debug = $this->debug;
2150 $ok = $this->db->Execute(
$sql );
2151 $this->db->debug = $saved;
2154 if( $this->
debug ) {
2155 ADOConnection::outp( $this->db->ErrorMsg() );
2176 function getSQL( $format = NULL, $sqlArray = NULL ) {
2177 if( !is_array( $sqlArray ) ) {
2178 $sqlArray = $this->sqlArray;
2181 if( !is_array( $sqlArray ) ) {
2185 switch( strtolower( $format ) ) {
2188 return !empty( $sqlArray ) ? implode(
";\n\n", $sqlArray ) .
';' :
'';
2190 return !empty( $sqlArray ) ? nl2br( htmlentities( implode(
";\n\n", $sqlArray ) .
';' ) ) :
'';
2193 return $this->sqlArray;
2203 ini_set(
"magic_quotes_runtime", $this->mgq );
2204 #set_magic_quotes_runtime( $this->mgq ); 2214 function logMsg( $msg, $title = NULL, $force = FALSE ) {
2215 if( XMLS_DEBUG or $force ) {
2218 if( isset( $title ) ) {
2219 echo
'<h3>' . htmlentities( $title ) .
'</h3>';
2222 if( is_object( $this ) ) {
2223 echo
'[' . get_class( $this ) .
'] ';
dbTable(&$parent, $attributes=NULL)
SchemaFileVersion( $filename)
_tag_open(&$parser, $tag, $attributes)
ExecuteSchema( $sqlArray=NULL, $continueOnErr=NULL)
_tag_close(&$parser, $tag)
RemoveSchemaString( $schema, $returnSchema=FALSE)
ConvertSchemaFile( $filename, $newVersion=NULL, $newFile=NULL)
ParseSchemaFile( $filename, $returnSchema=FALSE)
_file_get_contents($path)
if(!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE' E_USER_ERROR
_file_get_contents($file)
if(isset($_REQUEST['nrows'])) else $rs
ContinueOnError( $mode=NULL)
_tag_close(&$parser, $tag)
RemoveSchema( $filename, $returnSchema=FALSE)
supportedPlatform( $platform=NULL)
_tag_open(&$parser, $tag, $attributes)
_tag_open(&$parser, $tag, $attributes)
_tag_cdata(&$parser, $cdata)
_tag_close(&$parser, $tag)
SaveSQL( $filename='./schema.sql')
supportedPlatform( $platform=NULL)
_tag_close(&$parser, $tag)
prefixQuery( $regex, $query, $prefix=NULL)
_tag_cdata(&$parser, $cdata)
dbIndex(&$parent, $attributes=NULL)
ConvertSchemaString( $schema, $newVersion=NULL, $newFile=NULL)
_tag_cdata(&$parser, $cdata)
getSQL( $format=NULL, $sqlArray=NULL)
addFieldOpt( $field, $opt, $value=NULL)
_tag_open(&$parser, $tag, $attributes)
xslt_error_handler( $parser, $errno, $level, $fields)
addField( $name, $type, $size=NULL, $opts=NULL)
_tag_cdata(&$parser, $cdata)
_tag_close(&$parser, $tag)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
SetPrefix( $prefix='', $underscore=TRUE)
dbObject(&$parent, $attributes=NULL)
_tag_cdata(&$parser, $cdata)
SchemaStringVersion( $xmlstring)
TransformSchema( $schema, $xsl, $schematype='string')
dbData(&$parent, $attributes=NULL)
_tag_open(&$parser, $tag, $attributes)
ParseSchema( $filename, $returnSchema=FALSE)
_tag_open(&$parser, $tag, $attributes)
ParseSchemaString( $xmlstring, $returnSchema=FALSE)
debug($variable='', $name=' *variable *', $line=' *line *', $file=' *file *', $recursiveDepth=3, $debugLevel=E_DEBUG)
ExecuteInline( $mode=NULL)
ExtractSchema( $data=FALSE)
_tag_cdata(&$parser, $cdata)
dbQuerySet(&$parent, $attributes=NULL)
logMsg( $msg, $title=NULL, $force=FALSE)
_tag_close(&$parser, $tag)
PrintSQL( $format='NONE')
SetUpgradeMethod( $method='')