Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-17748

Expose options['result_buffering'] to CRM_Core_DAO

    Details

    • Versioning Impact:
      Major (incompatible API change)
    • Documentation Required?:
      None
    • Funding Source:
      Core Team Contract
    • Payment Status:
      Paid

      Description

      We have a custom contact search form task. The search parameters could easily result in more than 200k contacts being returned to this task, which often consumes PHP's memory_limit. Examination of the code shows that DB_mysql->simpleQuery() has the ability to use mysql_unbuffered_query() instead of mysql_query(), with the actual behavior determined by the setting of DB_mysql->options['result_buffering']. DB_common (and thus DB_mysql) has the setOption() method to allow for setting this option, but it is not utilized by CRM_Core_DAO. Given that CRM_Core_DAO is the fundamental object used for database interaction within Civi, I'd like to suggest allowing for manipulating DB_mysql->options from within the DAO object.

      1) create a setOptions() method for CRM_Core_DAO to allow for setting options within the DB_mysql object. The proper object to be referenced is found in the global $_DB_DATAOBJECT['CONNECTIONS'], indexed by CRM_Core_DAO->_database_dsn_md5.

      2) Modify CRM_Core_DAO->executeQuery() to recognize a new parameter. The new parameter should be an array("option_name"=>"option_value"), corresponding to the options available in DB_mysql->options. If the new parameter is populated, executeQuery() should call $dao->setOptions() prior to calling $dao->query().

      We like to get core team's thoughts on this change before implementing it in our own code.

        Attachments

        1. DAO.php
          61 kB
          Steve Binkowski

          Activity

            People

            • Assignee:
              lcdweb Brian Shaughnessy
              Reporter:
              s.bink Steve Binkowski
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Remaining Estimate - 1 day
                1d
                Logged:
                Time Spent - Not Specified
                Not Specified