我试图在 Joomla 中组合一个 SQL 字符串 -> 尝试连接到 MS SQL Server 实例,我有以下语法。我尝试使用echo $query;
在屏幕上显示字符串,但查询未显示在屏幕上。
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()));
}