I am attempting to put together a SQL String in Joomla -> Trying to connect to a MS SQL Server instance, and I have the below syntax. I have tried to use echo $query;
to display the string on screen, but the query is not displaying on screen.
What is the proper syntax using JDatabase
to string this together?
$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()));
}