1

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

4
  • 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. Sep 4 '21 at 13:37
  • module is CiviCRM extension, as CiviCRM has strcture similar to Drupal, hence - Sep 4 '21 at 19:36
  • 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. docs.civicrm.org/dev/en/latest/api
    – akosgarai
    Sep 5 '21 at 17:21
  • 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 Sep 5 '21 at 22:23
2

This document covers the steps of writing extensions. You can use the civix tool for generating the basics of your extension code. As your extension will execute database updates, you should take a look to this paragraph. The generated code contains examples for executing database queries.

I would like to suggest you to take a look to the 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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.