2009-10-08 64 views
0
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" 
    } 
+0

是否想從最新的對象(具有最高_date_的對象)獲取_value_字段?我認爲你應該嘗試編輯這個問題,並嘗試更具體地實現你想要達到的目標。 – csl 2009-10-08 08:42:34

+0

看看源代碼這說1000多個單詞 – streetparade 2009-10-08 08:54:34

回答

0

我解決我自己的問題的心不是那麼好對象?

$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; 
       } 


      } 

     }