Form Help

TOPIC:

Delete an entry from a database table 11 months 2 weeks ago #237503

  • Eddy.vh's Avatar Topic Author
  • Eddy.vh
  • Away
  • Gold Breezer
  • Gold Breezer
  • Posts: 383
  • Karma: 4
  • Thanks: 62
Hello.

I would like to know if, using a BreezingForms form, it is possible to delete an entry from a database table.

Ex. I have a line with a subscriber email:
If I activate a checkbox, can I delete the corresponding line with this query?
I need to manage the unsubscribing and deletion of subscribers for an extension that does not offer automation.

Does this query seem correct?

$subscriberEmail = ff_getSubmit('email');
$db->setQuery("DELETE from #__my_table WHERE email = ' $id_subscriberEmail'");

I was able to manage the registration using BreezingForms and the validation with BF + Integrator. Now, i need to manage the unsubscribing and deletion of subscribers for an extension that does not offer automation.

Thank you for your help.

Please Log in or Create an account to join the conversation.

Delete an entry from a database table 11 months 2 weeks ago #237542

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 414
Hello,

Your query seems fine.

If you wish to have a checkbox where the user decides whether to delete the account, then the code would go something like this:
if ( ff_getSubmit('checkboxName') == "checked") {
    $subscriberEmail = ff_getSubmit('email');
    $db->setQuery("DELETE from #__my_table WHERE email = ' 
    $id_subscriberEmail'");
    $db->execute();
}

That would delete a row in database table #__my_table where email corresponds to the email which was just entered in the form.

Let me know whether this is working as you wanted.

Regards,

Mihaela
The following user(s) said Thank You: Eddy.vh

Please Log in or Create an account to join the conversation.

Delete an entry from a database table 11 months 2 weeks ago #237544

  • Eddy.vh's Avatar Topic Author
  • Eddy.vh
  • Away
  • Gold Breezer
  • Gold Breezer
  • Posts: 383
  • Karma: 4
  • Thanks: 62
Mihaela,

You're fantastic, I've been looking for a solution for days and it seems I forgot to start the execution.
$db->execute();

I thank you and wish you an excellent weekend.

Please Log in or Create an account to join the conversation.

Delete an entry from a database table 11 months 2 weeks ago #237545

  • Eddy.vh's Avatar Topic Author
  • Eddy.vh
  • Away
  • Gold Breezer
  • Gold Breezer
  • Posts: 383
  • Karma: 4
  • Thanks: 62
Mihaela

One more question.
If I have to execute several queries, I suppose it is necessary to run $db->execute(); after each of them?

Please Log in or Create an account to join the conversation.

Delete an entry from a database table 11 months 1 week ago #237555

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 414
Hi Eddy,

I'm really glad I've helped and that this is now working for you. :)

I thought that $db->execute(); might be what you have been missing.

As for the "If I have to execute several queries, I suppose it is necessary to run $db->execute(); after each of them?", it depends on what kind of query you are writing.

Here is an example:
$db = JFactory::getDbo(); // Get Database Object
$db->setQuery('SELECT ...'); 
$result = $db->loadResult();

$db2 = JFactory::getDbo(); // Get Database Object
$db2->setQuery('DELETE ...'); 
$result = $db2->execute();
So, if you are fetching a value with, for example, SELECT query, then the database query will be run with functions like: loadResult(), loadObjectList(), loadAssoc() etc.

On the other hand, if you are writing a DELETE query, since no value is returned, it is necessary to have execute() function to run the query.

You can read more about setQuery function here docs.joomla.org/Selecting_data_using_JDatabase .

I hope this helps.

Regards,

Mihaela
The following user(s) said Thank You: Eddy.vh

Please Log in or Create an account to join the conversation.

Delete an entry from a database table 11 months 1 week ago #237559

  • Eddy.vh's Avatar Topic Author
  • Eddy.vh
  • Away
  • Gold Breezer
  • Gold Breezer
  • Posts: 383
  • Karma: 4
  • Thanks: 62
Hello Mihaela.

This weekend, I was able to do some tests and complete the project.
Thanks for your help, I was able to understand many things and especially how to read and write to a database, modify data in a database, and delete data that was no longer needed.

I finally rewrote the scripts to get a form capable of registering a subscriber, a subscription confirmation form activating the subscriber and placing him in a subscriber group.
The unsubscribe form deletes the subscriber and removes him from the group. And all this without having to use Integrator.

Thank you for your good tips.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.050 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

Summer Sale!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!