Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM_Utils_SQL_Select - Allow fluent query execution #10686

Merged
merged 3 commits into from
Jul 24, 2017

Commits on Jul 17, 2017

  1. CRM_Utils_SQL_Select - Allow fluent query execution

    When I first wrote `CRM_Utils_SQL_Select`, I was a bit dogmatic about
    loose-coupling and wanted the class to be entirely independent of the SQL
    runtime. But this is a bit annoying in usage and training.
    
    Before
    ======
    
    To build and execute query, you had to pass the rendered SQL to the execute
    function, eg
    
    ```php
    $select = CRM_Utils_SQL_Select::from('mytable')
      ->select('...')
    $dao = CRM_Core_DAO::executeQuery($select->toSQL());
    while ($dao->fetch()) { ... }
    ```
    
    After
    =====
    
    You can use more fluent style:
    
    ```php
    $dao = CRM_Utils_SQL_Select::from('mytable')
      ->select('...')
      ->execute();
    while ($dao->fetch()) { ... }
    ```
    
    And you can chain with other DAO functions like `fetchAll()` or
    `fetchValue()`.
    
    ```php
    $records = CRM_Utils_SQL_Select::from('mytable')
      ->select('...')
      ->execute()
      ->fetchAll();
    ```
    totten committed Jul 17, 2017
    Configuration menu
    Copy the full SHA
    77e74ae View commit details
    Browse the repository at this point in the history

Commits on Jul 20, 2017

  1. Configuration menu
    Copy the full SHA
    c4dcc9c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ee7d22e View commit details
    Browse the repository at this point in the history