Issues with conditions #1288
-
|
Hi everyone,
It either never displays the message or it always does when I try to play with the NOT for the WHERE and the NULL conditions (the session token part is copied from Nick Antonaccio's tutorial and works the other times it is used). The email addresses are supposed to be NULL by default unless they are filled by the administrator when creating the users. Thank you in advance to anyone who can help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Hi @monsieurmerle ! In SQLPage, you can use the functions provided by the database you are connected to . Which database are you using ? By default, when you don't configure a database, SQLPage uses SQLite. The list of date and time functions supported by SQLite is documented here: https://sqlite.org/lang_datefunc.html . Similar functions exist in Postgresql and in MySQL. In sqlite you could have a conditional alert like select 'alert' as component,
'Hurry up' as title,
'Maintenance is due in less than two days !' as description,
'red' as color
from maintenance
where
id = $id AND
datetime(due_date, '+0000-00-02') < current_date;
|
Beta Was this translation helpful? Give feedback.
-
|
For your second question about finding whether the current user has a professional email, what you want is probably select 'alert' as component, 'Missing email' as title
WHERE NOT EXISTS ( -- show the alert if no saved session has an associated user with an email
SELECT 1 FROM sessions s
JOIN clients_company c ON c.id = s.user_ide
WHERE s.session_token = sqlpage.cookie('session_token') AND
c.mail_pro IS NOT NULL
);Be careful and ensure that your mail_pro column really contains null, and not an empty string for instance, when the user has not filled in their email. |
Beta Was this translation helpful? Give feedback.

Hi @monsieurmerle !
In SQLPage, you can use the functions provided by the database you are connected to . Which database are you using ? By default, when you don't configure a database, SQLPage uses SQLite. The list of date and time functions supported by SQLite is documented here: https://sqlite.org/lang_datefunc.html . Similar functions exist in Postgresql and in MySQL.
In sqlite you could have a conditional alert like