'MCMS.Model.MMContent', 'comment' => 'MCMS.Model.MMComment' ); foreach ($tests as $table => $modelClass) { if ($db->tableExists($table)) { echo '
comparing table with model: '.$table.'
'; $targetTable = $db->table($table); $realClassName = import($modelClass); echo 'model class loaded: '.$modelClass.'
'; $mapping = call_user_func(array($realClassName,'fieldDBMapping')); $info = $targetTable->getInfo(); echo '
Comparing mapping list with existing table:
';
foreach ($mapping as $field=>$dbfield) {
$cid = $info->getColumnNum($dbfield);
if ($cid < 0)
echo 'field is missing in table: '.$dbfield.'
';
else
echo 'field found table: '.$dbfield.' has index '.$cid.'
';
}
echo '
Comparing existing table with mapping list:
';
for ($i = 0; $i < $info->getColumnCount(); $i++) {
$cinf = $info->getColumn($i);
if (($key = array_search($cinf->getName(),$mapping)) === false)
echo 'field is missing in model: '.$cinf->getName().'
';
else
echo 'field found in model: '.$cinf->getName().' as '.$key.'
';
}
}
else
echo '
table is missing: '.$table.'
'; } ?>