function addItem($id, $item)
 {
     if ($this->db == null) {
         return new PEAR_Error("DB Connect error.");
     }
     $logger =& Log::singleton("null", "results.log", "addItem");
     $logger->log($id . ": " . print_r($item, true));
     $sqlCheck = "SELECT * FROM items WHERE name = ? AND address = ?";
     $itemId =& $this->db->getOne($sqlCheck, array($item["name"], $item["address"]));
     if (isset($itemId) && !PEAR::isError($itemId)) {
         $logger->log("Update: {$itemId}");
         $sql = SqlUtils::getUpdateSQL("items", $item, "id = {$itemId}", array("lastdate" => "NOW()"));
         $res =& $this->db->query($sql, array_values($item));
         $sql = "\n\t\t\t\tINSERT INTO items_links (item_id, rubric_id) \n\t\t\t\t\tVALUES (?, ?)\n\t\t\t";
         $res =& $this->db->query($sql, array($itemId, $id));
         return $itemId;
     } else {
         $logger->log("Insert new");
         $sql = SqlUtils::getInsertSQL("items", $item, array("lastdate" => "NOW()"));
         $res =& $this->db->query($sql, array_values($item));
         $itemId =& $this->db->getOne($sqlCheck, array($item["name"], $item["address"]));
         if (isset($itemId)) {
             $logger->log("Id: " . $itemId);
             $sql = "\n\t\t\t\t\tINSERT INTO items_links (item_id, rubric_id) \n\t\t\t\t\t\tVALUES (?, ?)\n\t\t\t\t";
             $res =& $this->db->query($sql, array($itemId, $id));
             return $itemId;
         }
         return new PEAR_Error("Item ID is null");
     }
 }