2017-07-11 64 views
1

我試圖把一個SQL字符串放在一起Joomla - >試圖連接到一個MS SQL Server實例,並且我有下面的語法。我試圖使用echo $query;在屏幕上顯示字符串,但查詢不顯示在屏幕上。Joomla查詢連接字符串

什麼是正確的語法使用JDatabase串起來呢?

$query->select('select empfirstname, emplastname, empaddress, empcity, empstate'); 
$query->from($db->quoteName('[HiringInfo]')); 
$query->where("hiredate IS NOT NULL"); 
$dropdownlistDates = $db->quoteName('hiredate'); 
if (isset($sd) && isset($ed)) 
{ 
    $query->where("$dropdownlistDates >= " . $db->quote($sd), 'AND'); 
    $query->where("$dropdownlistDates <= " . $db->quote($ed)); 
} 
elseif (isset($datecriteria)) 
{ 
    if ($datecriteria != 15 
     && $datecriteria != 30 
     && $datecriteria != 45) 
    { 
     return null; 
    } 
    $min_date = DateAdd(day, $datecriteria * -1, getdate()); 
    $query->where("$dropdownlistDates >= " . $db->quote($min_date), 'AND'); 
    $query->where("$dropdownlistDates <= " . $db->quote(getdate())); 
} 

回答

1

您可以echo($query->__toString());

做,如果你使用mysql就可以看到所有的查詢日誌文件中執行,只有在的[mysqld]部分設置參數的my.cnf文件

general_log_file = /path/to/query.log

general_log = 1

+0

這是爲mssql - 現在會更新問題。 – BellHopByDayAmetuerCoderByNigh

+0

好的,我編輯我的答案 – Rinos