$sql = "SELECT * FROM crm_contacts WHERE contact_id = %1"; $params = array(1 => array($contactId, 'Integer')); $result = CRM_Core_DAO::executeQuery($sql, $params); while ($result->fetch()) { $firstName = $result->first_name; $lastName = $result->last_name; // Do something with first name and last name }
$sql = "UPDATE crm_contribution SET total_amount = %1 WHERE contribution_id = %2"; $params = array( 1 => array($newAmount, 'Money'), 2 => array($contributionId, 'Integer') ); CRM_Core_DAO::executeQuery($sql, $params);This example shows how to update a contribution record in the CRM database using the executeQuery function. The SQL query updates the total amount of the contribution, and parameters are used to pass in the new amount and the ID of the contribution to be updated. Package library: CRM_Core_DAO library.