【问题标题】:Getting The Last Changes since Last Value Change获取自上次值更改以来的最后一次更改
【发布时间】:2009-10-08 08:35:14
【问题描述】:
I want to check the last value changes.
Some times the objectId is the same as another objectId but the value can be different.
And i cant compare this to get the Last changes.
How do i do that?

这是对象

  object(stdClass)#38 (6) {
      ["id"]=>
      string(7) "1715680"
      ["objectId"]=>
      string(1) "1"
      ["type"]=>
      string(1) "0"
      ["field"]=>
      string(2) "30"
      ["value"]=>
      string(1) "3"
      ["date"]=>
      string(10) "1239982220"
    }
    object(stdClass)#39 (6) {
      ["id"]=>
      string(7) "1739382"
      ["objectId"]=>
      string(1) "1"
      ["type"]=>
      string(1) "0"
      ["field"]=>
      string(2) "30"
      ["value"]=>
      string(1) "3"
      ["date"]=>
      string(10) "1240588802"
    }
    object(stdClass)#40 (6) {
      ["id"]=>
      string(7) "1762456"
      ["objectId"]=>
      string(1) "1"
      ["type"]=>
      string(1) "0"
      ["field"]=>
      string(2) "30"
      ["value"]=>
      string(1) "0"
      ["date"]=>
      string(10) "1241195393"
    }

【问题讨论】:

  • 是否要从最新的对象(date 最高的对象)中获取 value 字段?我认为您应该尝试编辑问题并尝试更具体地说明您想要实现的目标。
  • 看看源代码,这有 1000 多字

标签: php object compare


【解决方案1】:

我解决了我自己的问题不是很好吗?

$changed = false;

        while($z = $this->db->fetch($m))
        {
            $array[$z->objectId][$z->field][] = $z;
        }

        for($i = 0; $i < count($array); $i++)
        {

            $blogs = $array[1][30];

            foreach($blogs as $blog)
            {
                $blogs[$i];
                if($blog->value != $blogs[$i]->value)
                {
                        $changed = true;
                }


            }

        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-22
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 2012-06-18
    • 2021-09-26
    相关资源
    最近更新 更多