Using AppGini 5.94 1132
I am having difficulty with a sqlValue statement. I am using this statement as I know that I will only receive either one result or none. I have tried loads of iterations and I always get the same result i.e bool(false). I have modelled the same statement in phpadmin and it works so I know the structure of my command is OK
The data that I am testing for is definitely on the table.
The table I am accessing is called TermDates and is structured as follows:-
TermID Integer, PK
AcademicYr YEAR
Term Integer
StartDate Date UNIQUE
EndDate Date UNIQUE
The code is inserted in hooks/tablename.php file as a before_insert hook. My latest iteration follows . I have tried dog ears('' ') around field names, I have taken out the CONCAT and tried it with just selecting Term, I have removed TermKey. I have tried "case as DATE" for $apptdatestring, StartDate and EndDate. I have even tried them as all CHAR. None worked!
Code: Select all
// Updating Term from the Terms table using the appt date
$apptdatestring = $data['ApptDate'];
$appdate = strtotime($apptdatestring);
$term = sqlValue("select CONCAT(TermDates.AcademicYr, "/", TermDates.Term) as TermKey from TermDates where '{$apptdatestring}' Between StartDate and EndDate");
var_dump($apptdatestring, $apptdate, $term);
exit;
The code modelled in phpadmin (that works fine) follows. At least this proves the table is not currupted in any way
Code: Select all
select CONCAT(TermDates.AcademicYr, "/", TermDates.Term) as TermKey from TermDates where '2021-3-3' Between StartDate and EndDate
string(8) "2021-3-3" NULL bool(false)
I know I am doing something completely stupid but if anyone could shed any light on this I would be grateful.