本文整理匯總了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;
}