Answers.Body: <p><a href="https://docs.civicrm.org/dev/en/latest/extensions/" rel="nofollow noreferrer">This document</a> covers the steps of writing extensions. You can use the <a href="https://docs.civicrm.org/dev/en/latest/extensions/civix/" rel="nofollow noreferrer">civix tool</a> for generating the basics of your extension code. As your extension will execute database updates, you should take a look to <a href="https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-upgrader" rel="nofollow noreferrer">this paragraph</a>. The generated code contains examples for executing database queries.</p>
  <p>I would like to suggest you to take a look to the <a href="https://docs.civicrm.org/dev/en/latest/api/#api-explorer" rel="nofollow noreferrer">api explorer</a> tool also. As you only need to update one row, you can define the api call in the explorer and then execute it. Maybe it is easier to write a script that calls the API of your sites, than developing an extension to do the same thing, but with sql queries.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-04T10:23:55.517Z
Answers.LastActivityDate: 2021-09-04T10:23:55.517Z
Answers.UserDisplayName: akosgarai
Body: <p>What I am trying to achieve - is to write a custom module(CiviCRM extension)/script, which should update( Run small SQL query to update about a missing &quot;Module&quot; )</p>
  <p>Basically - what the script will do(as civicrm is used in different CMS), so - CMS independently, update a row in <code>civicrm_option_value</code>.</p>
  <p>And, because of the project requirement - I need to make a script(extension), as there are multiple sites, and they are managed with git, and automated system.</p>
  <p>I could not find, or not familiar with CiviCRM specifications, what to write/which extension to make?</p>
  <p>What to do to achieve this? CiviCRM extension is the only way, as CiviCRM is used in different CMS systems, they have same CiviCRM tables in database, however, the CMS extension( like Drupal update hook will not work, as there could be wordpress sites too).</p>
  <p><strong>Edit :</strong> With <code>civix generate:upgrade</code>, inside generated module, it has a skeleton upgrade script. I want to keep a check(if option value is set false, then do not fire <code>install</code> script).</p>
  <p><strong>Because of no Documentation on CiviCRM classes, and functions, return values, objects</strong>, I can not understand, how to write, and call - check, a particular row.</p>
  <p>My question: What is the retuen value of <code>CiviCRM_Core_DAO</code> and <code>CiviCRM_Core_BAO</code>, how to determine, which value they send. Because of no-documentation, I am not sure - if I am asking right question</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-04T13:37:44.893Z
Comments.Text: Could you explain what you mean by 'module'? I wonder if you mean a Drupal module? But you say it needs to work with different CMSs.
Comments.UserDisplayName: William Mortada
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-04T19:36:45.147Z
Comments.Text: module is CiviCRM extension, as CiviCRM has strcture similar to Drupal, hence -
Comments.UserDisplayName: Susobhan Das
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-05T17:21:03.190Z
Comments.Text: What is wrong with the API solution that i mentioned in my answer? In the API explorer tool, you can try out everything, you can execute the API calls and check the response. It is possible to select one particular row from the database with API. Also possible to update one particular row with the API, so it could fulfill your need. And it is documented well. https://docs.civicrm.org/dev/en/latest/api/
Comments.UserDisplayName: akosgarai
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-05T22:23:35.510Z
Comments.Text: API3 is showing deprecated `update` so, no question trying with that. Another question **How to update a module without uninstalling/instaling, which is installed**, i.e. writing upgrader from inside the extension, now **how to call the upgrader** for the extension
Comments.UserDisplayName: Susobhan Das
Tags: <extension><database>
Title: How to write update script
ThreadText: # How to write update script
  
  (Asked by: username_0 on 2021-09-04)
  
  What I am trying to achieve - is to write a custom module(CiviCRM extension)/script, which should update( Run small SQL query to update about a missing "Module" )
  
  Basically - what the script will do(as civicrm is used in different CMS), so - CMS independently, update a row in `civicrm_option_value`.
  
  And, because of the project requirement - I need to make a script(extension), as there are multiple sites, and they are managed with git, and automated system.
  
  I could not find, or not familiar with CiviCRM specifications, what to write/which extension to make?
  
  What to do to achieve this? CiviCRM extension is the only way, as CiviCRM is used in different CMS systems, they have same CiviCRM tables in database, however, the CMS extension( like Drupal update hook will not work, as there could be wordpress sites too).
  
  **Edit :** With `civix generate:upgrade`, inside generated module, it has a skeleton upgrade script. I want to keep a check(if option value is set false, then do not fire `install` script).
  
  **Because of no Documentation on CiviCRM classes, and functions, return values, objects**, I can not understand, how to write, and call - check, a particular row.
  
  My question: What is the retuen value of `CiviCRM_Core_DAO` and `CiviCRM_Core_BAO`, how to determine, which value they send. Because of no-documentation, I am not sure - if I am asking right question
  
  **Tags:** extension, database
  
  > **Comments:**
  > **username_1**: Could you explain what you mean by 'module'? I wonder if you mean a Drupal module? But you say it needs to work with different CMSs.  
  > **username_0**: module is CiviCRM extension, as CiviCRM has strcture similar to Drupal, hence -  
  > **username_2**: What is wrong with the API solution that i mentioned in my answer? In the API explorer tool, you can try out everything, you can execute the API calls and check the response. It is possible to select one particular row from the database with API. Also possible to update one particular row with the API, so it could fulfill your need. And it is documented well. https://docs.civicrm.org/dev/en/latest/api/  
  > **username_0**: API3 is showing deprecated `update` so, no question trying with that. Another question **How to update a module without uninstalling/instaling, which is installed**, i.e. writing upgrader from inside the extension, now **how to call the upgrader** for the extension  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-09-04. Score: 2
  
  [This document](https://docs.civicrm.org/dev/en/latest/extensions/) covers the steps of writing extensions. You can use the [civix tool](https://docs.civicrm.org/dev/en/latest/extensions/civix/) for generating the basics of your extension code. As your extension will execute database updates, you should take a look to [this paragraph](https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-upgrader). The generated code contains examples for executing database queries.
  
  I would like to suggest you to take a look to the [api explorer](https://docs.civicrm.org/dev/en/latest/api/#api-explorer) tool also. As you only need to update one row, you can define the api call in the explorer and then execute it. Maybe it is easier to write a script that calls the API of your sites, than developing an extension to do the same thing, but with sql queries.
  
  
  ---
  
  