Egocentralis
Member
Hi all,
I have a yes no switch. If people say yes and save there will be data stored in the database. A new temporary user is made and also the details of that user are stored in the "employee" table.
Then, when users, say NO and save the form, I want the php plugin select the corresponding email address, and with that email address select an userid.
Then, I want to delete the row in the "employee" table containing that userid.
I wrote a query, To see if it is YES (1) or NO (0) to find the Company_id (bedrijf_id). Create the email address where we are looking for. With that email address it finds the correct userid. And till that part the query is working fine.
When I do Var_dump at the end, its showing the right id.
This is the query:
So, then I addes to the code an IF statement.
When $yesno == '0' then do....
I tried to write a query to delete the row, but its crashing the site if I save the form. It doesnt matter if I have 0 or 1 as a value.
How can I get this to work? Or what is wrong with the last query?
If I put a var_dump after if ($yesno == '0') { then it shows what i wanted to see.
But when $yesno = 1.. it isnt showing anything as expected.
But when I put the query after the if ($yesno == '0') {
Its crashing, and it does not matter if $yesno == 0 or $yesno==1.
How can i solve this?
I have a yes no switch. If people say yes and save there will be data stored in the database. A new temporary user is made and also the details of that user are stored in the "employee" table.
Then, when users, say NO and save the form, I want the php plugin select the corresponding email address, and with that email address select an userid.
Then, I want to delete the row in the "employee" table containing that userid.
I wrote a query, To see if it is YES (1) or NO (0) to find the Company_id (bedrijf_id). Create the email address where we are looking for. With that email address it finds the correct userid. And till that part the query is working fine.
When I do Var_dump at the end, its showing the right id.
This is the query:
Code:
$email_end = '@egocentralis.nl';
$userdel = "user deleted";
$user = JFactory::getUser();
$user_id = $user->get('id');
$db = FabrikWorker::getDbo();
$qyesno = $db->getQuery(true);
$qyesno
->select("ja_of_nee")
->from("test_hulp_op_afstand")
->where("bedrijf_id IN (SELECT bedrijf_id FROM egocentralis_bedrijven WHERE userid = " . $user_id . ") OR bedrijf_id IN (SELECT bedrijf_id FROM g4e_orakel_personeel WHERE userid = " . $user_id . " ) ");
$db->setQuery($qyesno);
$yesno = $db->loadResult();
$mydb = FabrikWorker::getDbo();
$qbedrid = $mydb->getQuery(true);
$qbedrid
->select("bedrijf_id")
->from("egocentralis_bedrijven")
->where("bedrijf_id IN (SELECT bedrijf_id FROM egocentralis_bedrijven WHERE userid = " . $user_id . ") OR bedrijf_id IN (SELECT bedrijf_id FROM g4e_orakel_personeel WHERE userid = " . $user_id . " ) ");
$mydb->setQuery($qbedrid);
$bedrid = $mydb->loadResult();
$gez_email = $bedrid . $email_end;
$mydb1 = FabrikWorker::getDbo();
$quserid = $mydb1->getQuery(true);
$quserid
->select('user_id_hulp')
->from('hulp_op_afstand')
->where('mail_hulp = ' . $mydb1->quote($gez_email));
$mydb1->setQuery($quserid);
$useridfinal = $mydb1->loadResult();
So, then I addes to the code an IF statement.
When $yesno == '0' then do....
I tried to write a query to delete the row, but its crashing the site if I save the form. It doesnt matter if I have 0 or 1 as a value.
Code:
if ($yesno == '0') {
$mydb1 = FabrikWorker::getDbo();
$query_delete = $mydb1->getQuery(true);
$query_delete
->delete('g4e_orakel_personeel')
->where('userid = ' . $mydb1->quote($useridfinal));
$mydb1->setQuery($query_delete);
$mydb1->execute();
)
How can I get this to work? Or what is wrong with the last query?
If I put a var_dump after if ($yesno == '0') { then it shows what i wanted to see.
But when $yesno = 1.. it isnt showing anything as expected.
But when I put the query after the if ($yesno == '0') {
Its crashing, and it does not matter if $yesno == 0 or $yesno==1.
How can i solve this?