Get all audit recordes for a module with Sugar Query?!

Is it possible to get all audit records for a specific module, Similar to a database query to load the table. Not only the ones linked to specific record.

What is the sugar query equivalent of this MySQL call;

SELECT *

FROM accounts_audit

Best regards

Gustav Lindstrom

Parents
  • 1) For example, you need get audit for module Accounts:

    $bean = new Account();

    $bean->retrieve($id); //audit log only for record

    $audit = new Audit();

    $audit_for_module = $audit->getAuditLog($bean);

    2) By custom query:

    $auditTable = 'Account';

    $query = "SELECT {$auditTable}.*

      FROM {$auditTable}

      ORDER BY {$auditTable}.date_created DESC";

    $db = DBManagerFactory::getInstance();

    $results = $db->query($query);


  • Not sure if I understand the answer, non of the alternatives is utilizing sugarquery. The second one seem to be loading the accounts table not the accounts_audit table?!

Reply Children
  • Gustav Lindström написал(а):

    ...The second one seem to be loading the accounts table not the accounts_audit table?!

    Yeah.. sorry.

    $auditTable = 'accounts_audit';