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) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • How to create extension database folders and write into table
Pages: [1]

Author Topic: How to create extension database folders and write into table  (Read 683 times)

anunalla

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: Drupal 7.33
  • MySQL version: 5.6.20
  • PHP version: 5.5.15
How to create extension database folders and write into table
November 13, 2014, 03:00:38 am
Hi,

I am new to creating CiviCRM extensions and I am trying to create a form to input student data and capture that data in civicrm database table. 
So far I have created the extension folder com.student.myextension and created the form (using civix generate:form) and custom coded the individual input fields. So basically I have a form ready.

My Question is:

1)   How to create the extension’s database folders(as per http://wiki.civicrm.org/confluence/display/CRM/CiviCRM+Database+Layer+for+Extensions) ?

I found a discussion in the forum which said the generate:table is still experimental and can use civix generate:entity.
But generate:entity does not create any files when i run it. (civix is the latest version)

Forum Link -http://forum.civicrm.org/index.php/topic,29354.msg125867.html#msg125867


2)   Also how do I write into the database table after that?

I am sorry if this may seem a basic question, but I am very new to this and would really appreciate if anyone could give me some guidance. I have searched the forums, but could not find a specific answer.

Thanks in Advance!

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: How to create extension database folders and write into table
November 13, 2014, 06:46:40 am
Would your data work as custom fields, or do you really need to create your own sql tables for it?
Custom fields may be easier, you can create them using the api.
Try asking your question on the new CiviCRM help site.

anunalla

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: Drupal 7.33
  • MySQL version: 5.6.20
  • PHP version: 5.5.15
Re: How to create extension database folders and write into table
November 13, 2014, 07:32:08 am
Thank you for your reply!

Yes I need to create a separate table.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to create extension database folders and write into table
November 13, 2014, 10:45:17 am
Since you are listed as 'drupal' is this a Drupal form - if so just checking you are aware of Webform-civicrm.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: How to create extension database folders and write into table
November 13, 2014, 11:15:27 am
If you are new to CiviCRM development, creating new entity tables in an extension is really diving into the deep end.
Simpler alternatives are
1) Custom fields, which in fact are sql tables, and can be created and managed by extensions fairly easily.
2) Settings - which are stored in a big blob of CiviCRM settings (probably not what you want but thought I'd mention it).

Or if you really (really) want to proceed with full-blown entities, here's roughly what you need to do:
  • Define the schema in an xml file like this
  • Run a patched version of setup.sh to generate your DAOs from the xml like this
  • Create one BAO file per DAO (they don't need to contain anything, but it's where you would put your business logic) [urlhttps://github.com/civicrm/org.civicrm.volunteer/tree/master/CRM/Volunteer/BAO]like this[/url]. Note that placement of all these files is important. Class-names must match up with path names, per Civi conventions.

CiviVolunteer is a fully-working example and probably a good one to follow if you have more questions I suggest you refer to that code.
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • How to create extension database folders and write into table

This forum was archived on 2017-11-26.