2016-11-23 46 views
-4

我需要交叉檢查兩個數據庫字段的是/否結果。我需要能夠交叉引用兩個數據庫字段

只是想知道下面是否與我需要做的事情有關。

((a + b) + c = d) if a + b are true and c is also true then return Yes 
((a + b) + c = d) if a + b are false and c is false then return No 
((a + b) + c = d) if a + b are true and c is false then return No 
((a + b) + c = d) if a + b are false and c is false then return No 

僞碼放在一邊,

我需要能夠把它變成PHP,如果我從公式中刪除b口返回結果完全正常,但增加額外的檢查只是返回空白。

@if ($report->subjectid == '2' && $report->subjectid == '3' && $report->metprogress == '1') Yes 

    @elseif ($report->subjectid === '2' && $report->subjectid == '3' && $report->metprogress == '4' or 
      $report->subjectid === '2' && $report->subjectid == '3' && $report->metprogress == '5') No 

@endif</td> 

這是我當前的代碼,顯然與僞代碼無關,因爲我試圖找出我需要的實際結構。

在此先感謝。

+0

你的第二排和第四排是一樣的嗎? ((a + b)+ c = d)如果a + b爲假並且c爲假然後返回否 – MrApnea

+0

我不明白這和數學有什麼關係。這只不過是語法學校的算術。 – duffymo

+2

「如果a + b是真的」是什麼意思?一分鐘這些看起來像數字,接下來他們是布爾人。投票結束,因爲它不清楚你問的是什麼,而不是數學。 – duffymo

回答

0

目前還不清楚你在問什麼。

但我認爲它是不可能的,該表達式計算爲TRUE:

$report->subjectid == '2' && $report->subjectid == '3' 

如果對象屬性subjectid等於'2',它不能也等於'3'。反之亦然。至少有一個條件不會評估爲TRUE。這意味着邏輯與運算的結果永遠不會計算爲TRUE。