CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How best to delete or remove contacts from view
Pages: [1]

Author Topic: How best to delete or remove contacts from view  (Read 1790 times)

kmitz

  • I post occasionally
  • **
  • Posts: 74
  • Karma: 2
How best to delete or remove contacts from view
January 07, 2009, 11:13:59 am
Hi,

We have to periodically update our db with a current voter registration database dump from an external source (approx. 16K names).  I do know about the contact import 'fill' method, but I also have a need to delete or hide the contacts who are no longer on the voter registration list, so it may be more convenient to update via a custom PHP script.

Any advice on how to either hide or delete contacts via SQL (prefer hiding)?  Is there a particular object method I can employ from existing CiviCRM code to delete or hide contacts?

Will deleting a contact from civicrm_contact cause a cascade of deletions across tables (I have limited SQL knowledge)?

Thanks,

kmitz

kmitz

  • I post occasionally
  • **
  • Posts: 74
  • Karma: 2
Re: How best to delete or remove contacts from view
January 07, 2009, 12:02:26 pm
I found a deleteContact method in CRM/Contact/BAO/Contact.php.  If I have a list of the civicrm_contact id's, it looks like I could use that...

Is the $userID variable my user ID (admin's or 1)?

Didn't see any way to hide the contacts rather than delete them, in the code or in the DB table.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: How best to delete or remove contacts from view
January 07, 2009, 12:38:33 pm

the userId is not used in that function. its some old code which i've cleaned up for 2.2. You can ignore it

there is no mechanism to "hide" contacts in CiviCRM. We'll potentially be adding this in a future release (i.e. soft delete)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

kmitz

  • I post occasionally
  • **
  • Posts: 74
  • Karma: 2
Re: How best to delete or remove contacts from view
January 07, 2009, 01:14:05 pm
Thanks Lobo.  I think I'm making this too hard for myself.  If I just delete the id from the civicrm_contact table, the delete will cascade, correct?  I tried it with one on a backup db and it seems to work like that.

PS I've been trying to instantiate CRM_Contact_BAO_Contact and I'm getting a DSN complaint from PHP, even though I've included the settings file...am I wasting my time with that?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: How best to delete or remove contacts from view
January 07, 2009, 01:48:49 pm

1. most of the related records are deleted (or set to null) via cascade. There are a couple of tables where we do this manually (civicrm_log).

2. Seems like you did not include the right settings file etc. You might want to take a look at the scripts in the bin directory and structure it similarly

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

kmitz

  • I post occasionally
  • **
  • Posts: 74
  • Karma: 2
Re: How best to delete or remove contacts from view
January 07, 2009, 02:48:58 pm
Quote
You might want to take a look at the scripts in the bin directory and structure it similarly

Awesome.  Thanks.

kmitz

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How best to delete or remove contacts from view

This forum was archived on 2017-11-26.