Answers.Body: <p>Installing civix and generating Extension using civix is the correct way you can find more details in the below link
  <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension" rel="nofollow">http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension</a></p>
  
  <p>Or</p>
  
  <p>For shortcut create an hook_civicrm_install and use the statement 
   $sql = "CREATE TABLE ";
   $dao = CRM_Core_DAO::executeQuery( $sql );</p>
  
  <p>The above code will do the trick - but always try to use the first method using civix</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-14T13:31:45.240Z
Answers.Text: civix generate:entity sounds like what the OP is looking for, but this carries a warning of being experimental and incomplete.
Answers.UserDisplayName: DaveFF
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-14T13:34:13.927Z
Answers.Text: civix:generate entity should do that if i am to use civix for this but i get this          [ErrorException]                                                             
    Warning: ini_set(): A session is active. You cannot change the session modu  
    le's ini settings at this time in /home/ayprograms/civicrm/buildkit/extern/  
    civix/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/S  
    torage/Handler/NativeFileSessionHandler.php line 56
Answers.UserDisplayName: Aka Rolence
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-14T13:58:13.173Z
Answers.Text: it seems like you have some PHP error please try the below link http://stackoverflow.com/questions/11384416/cant-use-ini-set-because-session-is-active this might help you
Answers.UserDisplayName: Ramesh - ARTECH Consultancy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-14T12:06:10.077Z
Answers.LastActivityDate: 2015-07-14T12:06:10.077Z
Answers.UserDisplayName: Ramesh - ARTECH Consultancy
Answers.Body: <p>You could possibly rewrite the question. "How do I define a new Entity type in my extension?"</p>
  
  <p>If that is the question you are asking, then the most up to date reference for adding an entity to an extension can be found here: <a href="https://docs.civicrm.org/dev/en/master/extensions/civix/#add-a-new-entity" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/master/extensions/civix/#add-a-new-entity</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-16T21:32:35.023Z
Answers.LastActivityDate: 2017-01-20T14:08:12.730Z
Answers.LastEditDate: 2017-01-20T14:08:12.730Z
Answers.UserDisplayName: michaelmcandrew
Body: <p>I have about 22 DB tables for my extension and more are coming in as I work on the extension, I need to be able to  automatically generate the DAO and BAO files to access these tables from my code, I followed this thread <a href="https://civicrm.stackexchange.com/questions/3534/how-do-i-add-a-new-table-to-my-extension?rq=1">How do I add a new table to my extension?</a> and it seems to be worked for the author of the post but I need more light on how generate the xml schema files if they can be generated and where do I run the xml/phpGencode.php  specified in the comment to get the DAO files.</p>
  
Tags: <extension>
Title: How to automatically generate DAO classes for my DB tables
ThreadText: # How to automatically generate DAO classes for my DB tables
  
  (Asked by: username_0 on 2015-07-14)
  
  I have about 22 DB tables for my extension and more are coming in as I work on the extension, I need to be able to automatically generate the DAO and BAO files to access these tables from my code, I followed this thread [How do I add a new table to my extension?](https://civicrm.stackexchange.com/questions/3534/how-do-i-add-a-new-table-to-my-extension?rq=1) and it seems to be worked for the author of the post but I need more light on how generate the xml schema files if they can be generated and where do I run the xml/phpGencode.php specified in the comment to get the DAO files.
  
  **Tags:** extension
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-07-14. Score: 2
  
  Installing civix and generating Extension using civix is the correct way you can find more details in the below link
  <http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension>
  
  Or
  
  For shortcut create an hook\_civicrm\_install and use the statement
  $sql = "CREATE TABLE ";
  $dao = CRM\_Core\_DAO::executeQuery( $sql );
  
  The above code will do the trick - but always try to use the first method using civix
  
  > **Comments:**
  > **username_2**: civix generate:entity sounds like what the OP is looking for, but this carries a warning of being experimental and incomplete.  
  > **username_0**: civix:generate entity should do that if i am to use civix for this but i get this          [ErrorException]                                                                Warning: ini_set(): A session is active. You cannot change the session modu     le's ini settings at this time in /home/ayprograms/civicrm/buildkit/extern/     civix/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/S     torage/Handler/NativeFileSessionHandler.php line 56  
  > **username_1**: it seems like you have some PHP error please try the below link http://stackoverflow.com/questions/11384416/cant-use-ini-set-because-session-is-active this might help you  
  
  ---
  
  ### Answer by username_3 on 2017-01-16. Score: 1
  
  You could possibly rewrite the question. "How do I define a new Entity type in my extension?"
  
  If that is the question you are asking, then the most up to date reference for adding an entity to an extension can be found here: <https://docs.civicrm.org/dev/en/master/extensions/civix/#add-a-new-entity>
  
  
  ---
  
  