1

I have a site with two books, each having about 300-350 pages each. I want to delete one of the book and its child pages.
I was able to load the pages using some custom coding. I also came across, node_delete() function which has the following code snippet:

db_delete('node')
  ->condition('nid', $nids, 'IN')
  ->execute();
db_delete('node_revision')
  ->condition('nid', $nids, 'IN')
  ->execute();
db_delete('history')
  ->condition('nid', $nids, 'IN')
  ->execute();
db_delete('node_access')
  ->condition('nid', $nids, 'IN')
  ->execute();

So, it deletes data from four tables; but I suspect there are other tables, from which the data needs to be deleted as well (one of them being book table). Could you please point out which of the tables needs to be checked?

2
  • Why do you want to delete the books from code instead of using User Interface in drupal ?
    – Anil Sagar
    Commented Oct 16, 2012 at 6:07
  • because as I mentioned, book has 300-350 child pages, and deleting that number of nodes from UI would be troublesome.
    – AjitS
    Commented Oct 16, 2012 at 6:08

1 Answer 1

0

book_delete module will address your issue !

Book Delete adds the ability to delete entire books to the book administration page (admin/content/book). It uses a batch operation to allow deletion of large books.

Take a backup of database before doing any delete actions :-)

It just worked as expected !! Follow below steps.

  • Install module
  • Clear Drupal Cache
  • Go to admin/content/book
  • Select the book you want to delete and click on delete book link next to it.
  • Confirm delete !

That's it :-)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.