|
Adodb Dokumentation
V5.14 8 Sept 2011
|


Öffentliche Methoden | |
| dbTable (&$parent, $attributes=NULL) | |
| _tag_open (&$parser, $tag, $attributes) | |
| _tag_cdata (&$parser, $cdata) | |
| _tag_close (&$parser, $tag) | |
| addIndex ($attributes) | |
| addData ($attributes) | |
| addField ($name, $type, $size=NULL, $opts=NULL) | |
| addFieldOpt ($field, $opt, $value=NULL) | |
| addTableOpt ($opt) | |
| create (&$xmls) | |
| drop () | |
| dbTable (&$parent, $attributes=NULL) | |
| _tag_open (&$parser, $tag, $attributes) | |
| _tag_cdata (&$parser, $cdata) | |
| _tag_close (&$parser, $tag) | |
| addIndex ($attributes) | |
| addData ($attributes) | |
| addField ($name, $type, $size=NULL, $opts=NULL) | |
| addFieldOpt ($field, $opt, $value=NULL) | |
| addTableOpt ($opt) | |
| create (&$xmls) | |
| drop () | |
Datenfelder | |
| $name | |
| $fields = array() | |
| $indexes = array() | |
| $opts = array() | |
| $current_field | |
| $drop_table | |
| $drop_field = array() | |
| $currentPlatform = true | |
Definiert in Zeile 206 der Datei adodb-xmlschema.inc.php.
| _tag_cdata | ( | &$ | parser, |
| $ | cdata | ||
| ) |
XML Callback to process CDATA elements
private
Erneute Implementation von dbObject.
Definiert in Zeile 319 der Datei adodb-xmlschema.inc.php.
{
switch( $this->currentElement ) {
// Table constraint
case 'CONSTRAINT':
if( isset( $this->current_field ) ) {
$this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
} else {
$this->addTableOpt( $cdata );
}
break;
// Table option
case 'OPT':
$this->addTableOpt( $cdata );
break;
default:
}
}

| _tag_cdata | ( | &$ | parser, |
| $ | cdata | ||
| ) |
XML Callback to process CDATA elements
private
Erneute Implementation von dbObject.
Definiert in Zeile 347 der Datei adodb-xmlschema03.inc.php.
{
switch( $this->currentElement ) {
// Table/field constraint
case 'CONSTRAINT':
if( isset( $this->current_field ) ) {
$this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
} else {
$this->addTableOpt( $cdata );
}
break;
// Table/field option
case 'OPT':
if( isset( $this->current_field ) ) {
$this->addFieldOpt( $this->current_field, $cdata );
} else {
$this->addTableOpt( $cdata );
}
break;
default:
}
}

| _tag_close | ( | &$ | parser, |
| $ | tag | ||
| ) |
XML Callback to process end elements
private
Erneute Implementation von dbObject.
Definiert in Zeile 343 der Datei adodb-xmlschema.inc.php.
{
$this->currentElement = '';
switch( strtoupper( $tag ) ) {
case 'TABLE':
$this->parent->addSQL( $this->create( $this->parent ) );
xml_set_object( $parser, $this->parent );
$this->destroy();
break;
case 'FIELD':
unset($this->current_field);
break;
}
}

| _tag_close | ( | &$ | parser, |
| $ | tag | ||
| ) |
XML Callback to process end elements
private
Erneute Implementation von dbObject.
Definiert in Zeile 375 der Datei adodb-xmlschema03.inc.php.
{
$this->currentElement = '';
switch( strtoupper( $tag ) ) {
case 'TABLE':
$this->parent->addSQL( $this->create( $this->parent ) );
xml_set_object( $parser, $this->parent );
$this->destroy();
break;
case 'FIELD':
unset($this->current_field);
break;
case 'OPT':
case 'CONSTRAINT':
$this->currentPlatform = true;
break;
default:
}
}

| _tag_open | ( | &$ | parser, |
| $ | tag, | ||
| $ | attributes | ||
| ) |
XML Callback to process start elements. Elements currently processed are: INDEX, DROP, FIELD, KEY, NOTNULL, AUTOINCREMENT & DEFAULT.
private
Erneute Implementation von dbObject.
Definiert in Zeile 262 der Datei adodb-xmlschema.inc.php.
{
$this->currentElement = strtoupper( $tag );
switch( $this->currentElement ) {
case 'INDEX':
if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
xml_set_object( $parser, $this->addIndex( $attributes ) );
}
break;
case 'DATA':
if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
xml_set_object( $parser, $this->addData( $attributes ) );
}
break;
case 'DROP':
$this->drop();
break;
case 'FIELD':
// Add a field
$fieldName = $attributes['NAME'];
$fieldType = $attributes['TYPE'];
$fieldSize = isset( $attributes['SIZE'] ) ? $attributes['SIZE'] : NULL;
$fieldOpts = isset( $attributes['OPTS'] ) ? $attributes['OPTS'] : NULL;
$this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
break;
case 'KEY':
case 'NOTNULL':
case 'AUTOINCREMENT':
// Add a field option
$this->addFieldOpt( $this->current_field, $this->currentElement );
break;
case 'DEFAULT':
// Add a field option to the table object
// Work around ADOdb datadict issue that misinterprets empty strings.
if( $attributes['VALUE'] == '' ) {
$attributes['VALUE'] = " '' ";
}
$this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
break;
case 'DEFDATE':
case 'DEFTIMESTAMP':
// Add a field option to the table object
$this->addFieldOpt( $this->current_field, $this->currentElement );
break;
default:
// print_r( array( $tag, $attributes ) );
}
}

| _tag_open | ( | &$ | parser, |
| $ | tag, | ||
| $ | attributes | ||
| ) |
XML Callback to process start elements. Elements currently processed are: INDEX, DROP, FIELD, KEY, NOTNULL, AUTOINCREMENT & DEFAULT.
private
Erneute Implementation von dbObject.
Definiert in Zeile 287 der Datei adodb-xmlschema03.inc.php.
{
$this->currentElement = strtoupper( $tag );
switch( $this->currentElement ) {
case 'INDEX':
if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
xml_set_object( $parser, $this->addIndex( $attributes ) );
}
break;
case 'DATA':
if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
xml_set_object( $parser, $this->addData( $attributes ) );
}
break;
case 'DROP':
$this->drop();
break;
case 'FIELD':
// Add a field
$fieldName = $attributes['NAME'];
$fieldType = $attributes['TYPE'];
$fieldSize = isset( $attributes['SIZE'] ) ? $attributes['SIZE'] : NULL;
$fieldOpts = !empty( $attributes['OPTS'] ) ? $attributes['OPTS'] : NULL;
$this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
break;
case 'KEY':
case 'NOTNULL':
case 'AUTOINCREMENT':
case 'DEFDATE':
case 'DEFTIMESTAMP':
case 'UNSIGNED':
// Add a field option
$this->addFieldOpt( $this->current_field, $this->currentElement );
break;
case 'DEFAULT':
// Add a field option to the table object
// Work around ADOdb datadict issue that misinterprets empty strings.
if( $attributes['VALUE'] == '' ) {
$attributes['VALUE'] = " '' ";
}
$this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
break;
case 'OPT':
case 'CONSTRAINT':
// Accept platform-specific options
$this->currentPlatform = ( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) );
break;
default:
// print_r( array( $tag, $attributes ) );
}
}

| addData | ( | $ | attributes | ) |
Adds data to a table object
| array | $attributes | Data attributes |
Definiert in Zeile 377 der Datei adodb-xmlschema.inc.php.
{
if( !isset( $this->data ) ) {
$this->data = new dbData( $this, $attributes );
}
return $this->data;
}

| addData | ( | $ | attributes | ) |
Adds data to a table object
| array | $attributes | Data attributes |
Definiert in Zeile 414 der Datei adodb-xmlschema03.inc.php.
{
if( !isset( $this->data ) ) {
$this->data = new dbData( $this, $attributes );
}
return $this->data;
}
| addField | ( | $ | name, |
| $ | type, | ||
| $ | size = NULL, |
||
| $ | opts = NULL |
||
| ) |
Adds a field to a table object
$name is the name of the table to which the field should be added. $type is an ADODB datadict field type. The following field types are supported as of ADODB 3.40:
| string | $name | Name of the table to which the field will be added. |
| string | $type | ADODB datadict field type. |
| string | $size | Field size |
| array | $opts | Field options array |
Definiert in Zeile 413 der Datei adodb-xmlschema.inc.php.
{
$field_id = $this->FieldID( $name );
// Set the field index so we know where we are
$this->current_field = $field_id;
// Set the field name (required)
$this->fields[$field_id]['NAME'] = $name;
// Set the field type (required)
$this->fields[$field_id]['TYPE'] = $type;
// Set the field size (optional)
if( isset( $size ) ) {
$this->fields[$field_id]['SIZE'] = $size;
}
// Set the field options
if( isset( $opts ) ) {
$this->fields[$field_id]['OPTS'][] = $opts;
}
}


| addField | ( | $ | name, |
| $ | type, | ||
| $ | size = NULL, |
||
| $ | opts = NULL |
||
| ) |
Adds a field to a table object
$name is the name of the table to which the field should be added. $type is an ADODB datadict field type. The following field types are supported as of ADODB 3.40:
| string | $name | Name of the table to which the field will be added. |
| string | $type | ADODB datadict field type. |
| string | $size | Field size |
| array | $opts | Field options array |
Definiert in Zeile 450 der Datei adodb-xmlschema03.inc.php.
{
$field_id = $this->FieldID( $name );
// Set the field index so we know where we are
$this->current_field = $field_id;
// Set the field name (required)
$this->fields[$field_id]['NAME'] = $name;
// Set the field type (required)
$this->fields[$field_id]['TYPE'] = $type;
// Set the field size (optional)
if( isset( $size ) ) {
$this->fields[$field_id]['SIZE'] = $size;
}
// Set the field options
if( isset( $opts ) ) {
$this->fields[$field_id]['OPTS'] = array($opts);
} else {
$this->fields[$field_id]['OPTS'] = array();
}
}

| addFieldOpt | ( | $ | field, |
| $ | opt, | ||
| $ | value = NULL |
||
| ) |
Adds a field option to the current field specifier
This method adds a field option allowed by the ADOdb datadict and appends it to the given field.
| string | $field | Field name |
| string | $opt | ADOdb field option |
| mixed | $value | Field option value |
Definiert in Zeile 447 der Datei adodb-xmlschema.inc.php.
{
if( !isset( $value ) ) {
$this->fields[$this->FieldID( $field )]['OPTS'][] = $opt;
// Add the option and value
} else {
$this->fields[$this->FieldID( $field )]['OPTS'][] = array( $opt => $value );
}
}


| addFieldOpt | ( | $ | field, |
| $ | opt, | ||
| $ | value = NULL |
||
| ) |
Adds a field option to the current field specifier
This method adds a field option allowed by the ADOdb datadict and appends it to the given field.
| string | $field | Field name |
| string | $opt | ADOdb field option |
| mixed | $value | Field option value |
Definiert in Zeile 486 der Datei adodb-xmlschema03.inc.php.
{
if( $this->currentPlatform ) {
if( !isset( $value ) ) {
$this->fields[$this->FieldID( $field )]['OPTS'][] = $opt;
// Add the option and value
} else {
$this->fields[$this->FieldID( $field )]['OPTS'][] = array( $opt => $value );
}
}
}

| addIndex | ( | $ | attributes | ) |
Adds an index to a table object
| array | $attributes | Index attributes |
Definiert in Zeile 365 der Datei adodb-xmlschema.inc.php.
{
$name = strtoupper( $attributes['NAME'] );
$this->indexes[$name] = new dbIndex( $this, $attributes );
return $this->indexes[$name];
}

| addIndex | ( | $ | attributes | ) |
Adds an index to a table object
| array | $attributes | Index attributes |
Definiert in Zeile 402 der Datei adodb-xmlschema03.inc.php.
{
$name = strtoupper( $attributes['NAME'] );
$this->indexes[$name] = new dbIndex( $this, $attributes );
return $this->indexes[$name];
}
| addTableOpt | ( | $ | opt | ) |
Adds an option to the table
This method takes a comma-separated list of table-level options and appends them to the table object.
| string | $opt | Table option |
Definiert in Zeile 465 der Datei adodb-xmlschema.inc.php.
{
if(isset($this->currentPlatform)) {
$this->opts[$this->parent->db->databaseType] = $opt;
}
return $this->opts;
}

| addTableOpt | ( | $ | opt | ) |
Adds an option to the table
This method takes a comma-separated list of table-level options and appends them to the table object.
| string | $opt | Table option |
Definiert in Zeile 506 der Datei adodb-xmlschema03.inc.php.
{
if(isset($this->currentPlatform)) {
$this->opts[$this->parent->db->databaseType] = $opt;
}
return $this->opts;
}
| create | ( | &$ | xmls | ) |
Generates the SQL that will create the table in the database
| object | $xmls | adoSchema object |
Erneute Implementation von dbObject.
Definiert in Zeile 479 der Datei adodb-xmlschema.inc.php.
{
$sql = array();
// drop any existing indexes
if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) {
foreach( $legacy_indexes as $index => $index_details ) {
$sql[] = $xmls->dict->DropIndexSQL( $index, $this->name );
}
}
// remove fields to be dropped from table object
foreach( $this->drop_field as $field ) {
unset( $this->fields[$field] );
}
// if table exists
if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) {
// drop table
if( $this->drop_table ) {
$sql[] = $xmls->dict->DropTableSQL( $this->name );
return $sql;
}
// drop any existing fields not in schema
foreach( $legacy_fields as $field_id => $field ) {
if( !isset( $this->fields[$field_id] ) ) {
$sql[] = $xmls->dict->DropColumnSQL( $this->name, '`'.$field->name.'`' );
}
}
// if table doesn't exist
} else {
if( $this->drop_table ) {
return $sql;
}
$legacy_fields = array();
}
// Loop through the field specifier array, building the associative array for the field options
$fldarray = array();
foreach( $this->fields as $field_id => $finfo ) {
// Set an empty size if it isn't supplied
if( !isset( $finfo['SIZE'] ) ) {
$finfo['SIZE'] = '';
}
// Initialize the field array with the type and size
$fldarray[$field_id] = array(
'NAME' => $finfo['NAME'],
'TYPE' => $finfo['TYPE'],
'SIZE' => $finfo['SIZE']
);
// Loop through the options array and add the field options.
if( isset( $finfo['OPTS'] ) ) {
foreach( $finfo['OPTS'] as $opt ) {
// Option has an argument.
if( is_array( $opt ) ) {
$key = key( $opt );
$value = $opt[key( $opt )];
@$fldarray[$field_id][$key] .= $value;
// Option doesn't have arguments
} else {
$fldarray[$field_id][$opt] = $opt;
}
}
}
}
if( empty( $legacy_fields ) ) {
// Create the new table
$sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
logMsg( end( $sql ), 'Generated CreateTableSQL' );
} else {
// Upgrade an existing table
logMsg( "Upgrading {$this->name} using '{$xmls->upgrade}'" );
switch( $xmls->upgrade ) {
// Use ChangeTableSQL
case 'ALTER':
logMsg( 'Generated ChangeTableSQL (ALTERing table)' );
$sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts );
break;
case 'REPLACE':
logMsg( 'Doing upgrade REPLACE (testing)' );
$sql[] = $xmls->dict->DropTableSQL( $this->name );
$sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
break;
// ignore table
default:
return array();
}
}
foreach( $this->indexes as $index ) {
$sql[] = $index->create( $xmls );
}
if( isset( $this->data ) ) {
$sql[] = $this->data->create( $xmls );
}
return $sql;
}

| create | ( | &$ | xmls | ) |
Generates the SQL that will create the table in the database
| object | $xmls | adoSchema object |
Erneute Implementation von dbObject.
Definiert in Zeile 520 der Datei adodb-xmlschema03.inc.php.
{
$sql = array();
// drop any existing indexes
if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) {
foreach( $legacy_indexes as $index => $index_details ) {
$sql[] = $xmls->dict->DropIndexSQL( $index, $this->name );
}
}
// remove fields to be dropped from table object
foreach( $this->drop_field as $field ) {
unset( $this->fields[$field] );
}
// if table exists
if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) {
// drop table
if( $this->drop_table ) {
$sql[] = $xmls->dict->DropTableSQL( $this->name );
return $sql;
}
// drop any existing fields not in schema
foreach( $legacy_fields as $field_id => $field ) {
if( !isset( $this->fields[$field_id] ) ) {
$sql[] = $xmls->dict->DropColumnSQL( $this->name, $field->name );
}
}
// if table doesn't exist
} else {
if( $this->drop_table ) {
return $sql;
}
$legacy_fields = array();
}
// Loop through the field specifier array, building the associative array for the field options
$fldarray = array();
foreach( $this->fields as $field_id => $finfo ) {
// Set an empty size if it isn't supplied
if( !isset( $finfo['SIZE'] ) ) {
$finfo['SIZE'] = '';
}
// Initialize the field array with the type and size
$fldarray[$field_id] = array(
'NAME' => $finfo['NAME'],
'TYPE' => $finfo['TYPE'],
'SIZE' => $finfo['SIZE']
);
// Loop through the options array and add the field options.
if( isset( $finfo['OPTS'] ) ) {
foreach( $finfo['OPTS'] as $opt ) {
// Option has an argument.
if( is_array( $opt ) ) {
$key = key( $opt );
$value = $opt[key( $opt )];
@$fldarray[$field_id][$key] .= $value;
// Option doesn't have arguments
} else {
$fldarray[$field_id][$opt] = $opt;
}
}
}
}
if( empty( $legacy_fields ) ) {
// Create the new table
$sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
logMsg( end( $sql ), 'Generated CreateTableSQL' );
} else {
// Upgrade an existing table
logMsg( "Upgrading {$this->name} using '{$xmls->upgrade}'" );
switch( $xmls->upgrade ) {
// Use ChangeTableSQL
case 'ALTER':
logMsg( 'Generated ChangeTableSQL (ALTERing table)' );
$sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts );
break;
case 'REPLACE':
logMsg( 'Doing upgrade REPLACE (testing)' );
$sql[] = $xmls->dict->DropTableSQL( $this->name );
$sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
break;
// ignore table
default:
return array();
}
}
foreach( $this->indexes as $index ) {
$sql[] = $index->create( $xmls );
}
if( isset( $this->data ) ) {
$sql[] = $this->data->create( $xmls );
}
return $sql;
}
| dbTable | ( | &$ | parent, |
| $ | attributes = NULL |
||
| ) |
Iniitializes a new table object.
| string | $prefix | DB Object prefix |
| array | $attributes | Array of table attributes. |
Definiert in Zeile 251 der Datei adodb-xmlschema.inc.php.

| dbTable | ( | &$ | parent, |
| $ | attributes = NULL |
||
| ) |
Iniitializes a new table object.
| string | $prefix | DB Object prefix |
| array | $attributes | Array of table attributes. |
Definiert in Zeile 276 der Datei adodb-xmlschema03.inc.php.

| drop | ( | ) |
Marks a field or table for destruction
Definiert in Zeile 588 der Datei adodb-xmlschema.inc.php.
{
if( isset( $this->current_field ) ) {
// Drop the current field
logMsg( "Dropping field '{$this->current_field}' from table '{$this->name}'" );
// $this->drop_field[$this->current_field] = $xmls->dict->DropColumnSQL( $this->name, $this->current_field );
$this->drop_field[$this->current_field] = $this->current_field;
} else {
// Drop the current table
logMsg( "Dropping table '{$this->name}'" );
// $this->drop_table = $xmls->dict->DropTableSQL( $this->name );
$this->drop_table = TRUE;
}
}

| drop | ( | ) |
Marks a field or table for destruction
Definiert in Zeile 629 der Datei adodb-xmlschema03.inc.php.
{
if( isset( $this->current_field ) ) {
// Drop the current field
logMsg( "Dropping field '{$this->current_field}' from table '{$this->name}'" );
// $this->drop_field[$this->current_field] = $xmls->dict->DropColumnSQL( $this->name, $this->current_field );
$this->drop_field[$this->current_field] = $this->current_field;
} else {
// Drop the current table
logMsg( "Dropping table '{$this->name}'" );
// $this->drop_table = $xmls->dict->DropTableSQL( $this->name );
$this->drop_table = TRUE;
}
}