本文整理汇总了PHP中commonModel::diff方法的典型用法代码示例。如果您正苦于以下问题:PHP commonModel::diff方法的具体用法?PHP commonModel::diff怎么用?PHP commonModel::diff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类commonModel
的用法示例。
在下文中一共展示了commonModel::diff方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createChanges
/**
* Create changes of one object.
*
* @param mixed $old the old object
* @param mixed $new the new object
* @static
* @access public
* @return array
*/
public static function createChanges($old, $new)
{
global $config;
$changes = array();
$magicQuote = get_magic_quotes_gpc();
foreach ($new as $key => $value) {
if (strtolower($key) == 'lastediteddate') {
continue;
}
if (strtolower($key) == 'lasteditedby') {
continue;
}
if (strtolower($key) == 'assigneddate') {
continue;
}
if (strtolower($key) == 'editedby') {
continue;
}
if (strtolower($key) == 'editeddate') {
continue;
}
if ($magicQuote) {
$value = stripslashes($value);
}
if ($value != stripslashes($old->{$key})) {
$diff = '';
if (substr_count($value, "\n") > 1 or substr_count($old->{$key}, "\n") > 1 or strpos('name,title,desc,spec,steps,content,digest,verify,report', strtolower($key)) !== false) {
$diff = commonModel::diff($old->{$key}, $value);
}
$changes[] = array('field' => $key, 'old' => $old->{$key}, 'new' => $value, 'diff' => $diff);
}
}
return $changes;
}
示例2: createChanges
/**
* Create changes of one object.
*
* @param mixed $old the old object
* @param mixed $new the new object
* @static
* @access public
* @return array
*/
public static function createChanges($old, $new)
{
global $config;
$changes = array();
$magicQuote = get_magic_quotes_gpc();
foreach ($new as $key => $value) {
if (!isset($old->{$key})) {
continue;
}
if (strtolower($key) == 'lastediteddate') {
continue;
}
if (strtolower($key) == 'lasteditedby') {
continue;
}
if (strtolower($key) == 'assigneddate') {
continue;
}
if (strtolower($key) == 'editedby') {
continue;
}
if (strtolower($key) == 'editeddate') {
continue;
}
if (is_array($value)) {
if (is_string(reset($value))) {
$value = join(',', $value);
} else {
$value = join(',', array_keys($value));
}
}
if (is_array($old->{$key})) {
if (is_string(reset($old->{$key}))) {
$old->{$key} = join(',', $old->{$key});
} else {
$old->{$key} = join(',', array_keys($old->{$key}));
}
}
if ($magicQuote) {
$value = stripslashes($value);
}
if ($value != stripslashes($old->{$key})) {
$diff = '';
if (substr_count($value, "\n") > 1 or substr_count($old->{$key}, "\n") > 1 or strpos('name,title,desc,content,summary', strtolower($key)) !== false) {
$diff = commonModel::diff($old->{$key}, $value);
}
$changes[] = array('field' => $key, 'old' => $old->{$key}, 'new' => $value, 'diff' => $diff);
}
}
return $changes;
}