-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCargoTableSchema.php
34 lines (29 loc) · 980 Bytes
/
CargoTableSchema.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* Ideally this would probably implement the "Iterator" interface, but that
* seems like too much work for the limited usage this class gets.
*
* @author Yaron Koren
* @ingroup Cargo
*/
class CargoTableSchema {
var $mFieldDescriptions = array();
public static function newFromDBString( $dbString ) {
$tableSchema = new CargoTableSchema();
$tableSchemaDBArray = unserialize( $dbString );
if ( !is_array( $tableSchemaDBArray ) ) {
throw new MWException( "Invalid field information found for table." );
}
foreach ( $tableSchemaDBArray as $fieldName => $fieldDBArray ) {
$tableSchema->mFieldDescriptions[$fieldName] = CargoFieldDescription::newFromDBArray( $fieldDBArray );
}
return $tableSchema;
}
function toDBString() {
$tableSchemaDBArray = array();
foreach ( $this->mFieldDescriptions as $fieldName => $fieldDesc ) {
$tableSchemaDBArray[$fieldName] = $fieldDesc->toDBArray();
}
return serialize( $tableSchemaDBArray );
}
}