[SOLVED] Â Check if specific record exists |
1/9/2017 4:23:12 PM |
PHPRunner General questions | |
R
reimic author
hi, |
|
B
|
bencroftweb 1/9/2017 |
hi, I want use the following code in the Before record added event but it is don't work. thank you for you help. //** Check if specific record exists **** $strSQLExists = "select * from public.hr_conge where public.hr_conge.usager=$_SESSION["UserID"] and public.hr_conge.date ='" . $values["date"] . "'"; $rsExists = db_query($strSQLExists); $data=db_fetch_array($rsExists); if($data) { // if record exists do something $message = "date " . $values["date"] . " already exists." return false; } else { // if dont exist do something else }
|
B
|
bencroftweb 1/9/2017 |
Agreed - This does not work. It's something around the return false;
|
R
|
reimic author 1/10/2017 |
Doing a little searching on this forum I found a suggestion to remove the return false and put the semi colon after exists." { // if record exists do something $message = "date " . $values["date"] . " already exists."; } else { // if dont exist do something else } Yet to try it but might be worth a whirl :-)
|
R
|
reimic author 1/11/2017 |
thanks I have the problem with this line because it don't works : $strSQLExists = "select * from public.hr_conge where public.hr_conge.usager=243 and public.hr_conge.date ='" . $values["date"] . "'"; this is my ref: https://asprunner.com/phprunner/docs/check_if_specific_record_exists.htm
|
L
|
laonian 1/11/2017 |
Can you try this? $strSQLExists = "select * from public.hr_conge where public.hr_conge.date ='".date('Y-m-d',strtotime($values["date"]))."'"; [/size] |
R
|
reimic author 1/13/2017 |
thanks but it's not ok |
L
|
laonian 1/13/2017 |
You have several errors in your query. I am not the expert, but try to provide you with some code. Try this and see if it works.
|
R
|
reimic author 1/14/2017 |
You have several errors in your query. I am not the expert, but try to provide you with some code. Try this and see if it works. Event code before record added.
|