在我沒有收到任何回覆之前,我問這個問題,如果這有幫助,我決定重新發布它。我希望我沒有通過重新發布做任何錯誤?Codeigniter邏輯運算符
$total_cost_for_A = $this->admin_model->total_cost_for_A($branch, $department, $date);
$total_cost_for_B = $this->admin_model->total_cost_for_B($branch, $department, $date);
變量 $ total_cost_for_A和$ total_cost_for_B持有從模型中的一個MySQL查詢總和返回值。如果沒有找到記錄,則查詢返回false。現在,我正在嘗試執行此操作。
if(($total_cost_for_A === FALSE) && ($total_cost_for_B === FALSE))
{
$data['no_record'] = 'No Record Found!';
$this->load->view('admin/bookings', $data);
}
else
{
$this->load->view('admin/summary', $data);
}
該測試總是失敗並執行else語句,而不是這個。任何援助將不勝感激。由於
下面是功能
function total_cost_for_A($branch, $department, $date)
{
if($branch == 'Head Office' && $department == 'Summary')
{
$select_amount_paid = 'SELECT SUM(total_amount) total_amount FROM graphics_booking AS bk
WHERE bk.date = "'.$date.'"';
}
$result = $this->db->query($select_amount_paid);
if($result->num_rows() > 0)
{
return $result;
}
else
{
return FALSE;
}
}
function total_cost_for_B($branch, $department, $date)
{
if($branch == 'Head Office' && $department == 'Summary')
{
$total_LF_amount = 'SELECT SUM(total_amount) total_amount FROM large_format_print
WHERE date = "'.$date.'"';
}
$result = $this->db->query($total_LF_amount);
if($result->num_rows() > 0)
{
return $result;
}
else
{
return FALSE;
}
}
是的,你是。耐心一點。 @ dm03514給了一個很好的答案。請解決這個[在其他線程](http://stackoverflow.com/questions/12323539/php-codeigniter-logical-operator)。被標記關閉。 –
有人應該把它取下來。對不起 – sality