database = $in_database; } public function get_readings_by_date(\DateTime $datetime, string $reading_type) { return $this->database->query( "SELECT $this->table_name_values.*, $this->table_name_metadata.device_id, COALESCE( $this->table_name_metadata.$this->column_metadata_recordedon, $this->table_name_metadata.$this->column_metadata_storedon ) AS datetime, COALESCE( $this->table_name_metadata.$this->column_metadata_lat, {MariaDBDeviceRepository::$table_name}.device_latitude ) AS latitude, COALESCE( $this->table_name_metadata.$this->column_metadata_long, devices.device_longitude ) AS longitude FROM $this->table_name_values JOIN $this->table_name_metadata ON $this->table_name_values.$this->column_values_reading_id = $this->table_name_metadata.id JOIN devices ON $this->table_name_metadata.$this->column_metadata_device_id = devices.device_id WHERE COALESCE( $this->table_name_metadata.$this->column_metadata_recordedon, $this->table_name_metadata.$this->column_metadata_storedon ) = :datetime", [ "datetime" => $datetime, "reading_type" => $reading_type ] )->fetchAll(); } }