【问题标题】:Get modified fields on update with Zend使用 Zend 在更新时获取修改的字段
【发布时间】:2013-04-24 10:09:09
【问题描述】:

我正在尝试捕捉 ZEND 更新,以查看谁修改了什么。 我在 ZEND 框架源代码中找到了函数更新。像这样

public function update($table, array $bind, $where = '')
{
    global $Profiling;
    try 
    {
        return $this->dbInstance->update($table, $bind,$where);
    }
    catch (Zend_Exception $e) {
        $this->write_log($Profiling,"update " . $table,$e);
    }
}

所以我有桌子,我有地方。和所有的领域。完美的。 但是,有一个问题,当我对 $bind 变量执行 print_r 时。我已显示所有字段。

Array
(
    [mail] => Test_Droit_Utilisateur@osef.com
    [lastName] => testlastname
    [firstName] => TestFirstName
    [v_gender_id] => 2
    [active] => 1
    [adress] => 56 rue test
)

我不知道真正修改了什么。所有数据都通过版本页面上的表格发布。例如,当我只修改邮件时,print_r 将显示 $bind 变量中的所有信息。不可能知道真正修改了什么。 我想我可以在字段上花点时间,并将每个字段值与这个 $bind 变量进行比较。但效率不是很高,因为在几个表上,我有很多字段。

如果有人可以帮助我找到解决方案。我已经准备好了 :) 谢谢大家的建议。

【问题讨论】:

    标签: php mysql zend-framework profiling sql-update


    【解决方案1】:

    你可以使用

    array_diff_assoc($bind,$valuesfromDatabase);
    

    【讨论】:

      猜你喜欢
      • 2010-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-18
      • 1970-01-01
      • 2019-09-28
      • 1970-01-01
      相关资源
      最近更新 更多