Currently I am failing at the simplest of places.
I am counting entries in the database and asking if the value is greater than 2. Even though there are no entries, it gives me my error message that should only be displayed if there are more than 2 entries.
$newdate = date( 'Y-m-d', $fromform->date );
$comparedate = $DB->sql_compare_text('datum');
$comparedateplaceholder = $DB->sql_compare_text(':date');
$compareustd = $DB->sql_compare_text('ustd');
$compareustdplaceholder = $DB->sql_compare_text(':ustd');
$laptops = $DB->get_records_sql(
"SELECT COUNT(*) FROM {bs_steinweg} WHERE
{$comparedate} = {$comparedateplaceholder}
AND
{$compareustd} = {$compareustdplaceholder}",
[
'date' => $newdate,
'ustd' => $fromform->time,
]
);
var_dump($laptops);
if ( $laptops > 2 ) {
$getlaptops = get_string( 'laptopnotfree', 'local_buchungssystem' );
redirect( $CFG->wwwroot . '/local/buchungssystem/bs_sw.php', $getlaptops, null, 'coreoutputnotification::NOTIFY_WARNING' );
} else {
The following gives me: var_dump($laptops);
array(1) { [0]=> object(stdClass)#390 (1) { ["count(*)"]=> string(1) "0" } }
I understand correctly that var_dump() gives me a 0, right?
Where exactly is the error?