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 to correctly do an INSERT or UPDATE with DAO?
Pages: [1]

Author Topic: How to correctly do an INSERT or UPDATE with DAO?  (Read 944 times)

jsherk

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 0
How to correctly do an INSERT or UPDATE with DAO?
April 26, 2010, 01:49:05 pm
So far I have this:
Code: [Select]
  $dao = new CRM_Core_DAO;
  $dao->__table = 'civicrm_contact';
  $dao->contact_type = 'Individual';
  $dao->first_name = 'memyself';
  $dao->last_name = 'andi';
  $dao->insert();

But I keep getting this error:
Code: [Select]
DB_DataObject Error: insert:No table definition for civicrm_contact
And I cannot figure out how to set the table definition.

Also, is an update done exactly the same, except using $dao->update() or $dao->update(TRUE) instead?

Thanks

jsherk

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 0
Re: How to correctly do an INSERT or UPDATE with DAO?
April 27, 2010, 07:35:56 am
I have sort of figured it out... I posted it in wiki cheat sheet:
http://wiki.civicrm.org/confluence/display/CRMDOC/Civi-Cheat-Sheet

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How to correctly do an INSERT or UPDATE with DAO?

This forum was archived on 2017-11-26.