本文整理汇总了PHP中MDB2_Schema::arrayMergeClobber方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2_Schema::arrayMergeClobber方法的具体用法?PHP MDB2_Schema::arrayMergeClobber怎么用?PHP MDB2_Schema::arrayMergeClobber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2_Schema
的用法示例。
在下文中一共展示了MDB2_Schema::arrayMergeClobber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compareTableDefinitions
/**
* Compare a previous definition with the currently parsed definition
*
* @param string $table_name name of the table
* @param array $current_definition multi dimensional array that contains the current definition
* @param array $previous_definition multi dimensional array that contains the previous definition
* @param array &$defined_tables table names in the schema
*
* @return array|MDB2_Error array of changes on success, or a error object
* @access public
*/
function compareTableDefinitions($table_name, $current_definition, $previous_definition, &$defined_tables)
{
$changes = array();
if (is_array($current_definition)) {
$was_table_name = $table_name;
if (!empty($current_definition['was'])) {
$was_table_name = $current_definition['was'];
}
if (!empty($previous_definition[$was_table_name])) {
$changes['change'][$was_table_name] = array();
if ($was_table_name != $table_name) {
$changes['change'][$was_table_name] = array('name' => $table_name);
}
if (!empty($defined_tables[$was_table_name])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_INVALID, null, null, 'the table "' . $was_table_name . '" was specified for more than one table of the database');
}
$defined_tables[$was_table_name] = true;
if (!empty($current_definition['fields']) && is_array($current_definition['fields'])) {
$previous_fields = array();
if (isset($previous_definition[$was_table_name]['fields']) && is_array($previous_definition[$was_table_name]['fields'])) {
$previous_fields = $previous_definition[$was_table_name]['fields'];
}
$change = $this->compareTableFieldsDefinitions($table_name, $current_definition['fields'], $previous_fields);
if (PEAR::isError($change)) {
return $change;
}
if (!empty($change)) {
$changes['change'][$was_table_name] = MDB2_Schema::arrayMergeClobber($changes['change'][$was_table_name], $change);
}
}
if (!empty($current_definition['indexes']) && is_array($current_definition['indexes'])) {
$previous_indexes = array();
if (isset($previous_definition[$was_table_name]['indexes']) && is_array($previous_definition[$was_table_name]['indexes'])) {
$previous_indexes = $previous_definition[$was_table_name]['indexes'];
}
$change = $this->compareTableIndexesDefinitions($table_name, $current_definition['indexes'], $previous_indexes);
if (PEAR::isError($change)) {
return $change;
}
if (!empty($change)) {
$changes['change'][$was_table_name]['indexes'] = $change;
}
}
if (empty($changes['change'][$was_table_name])) {
unset($changes['change'][$was_table_name]);
}
if (empty($changes['change'])) {
unset($changes['change']);
}
} else {
if ($table_name != $was_table_name) {
return $this->raiseError(MDB2_SCHEMA_ERROR_INVALID, null, null, 'it was specified a previous table name ("' . $was_table_name . '") for table "' . $table_name . '" that does not exist');
}
$changes['add'][$table_name] = true;
}
}
return $changes;
}