$dao = CRM_Core_DAO::executeQuery("SELECT last_name FROM civicrm_contact WHERE id = %1", array(1 => array($contactId, 'Integer'))); $lastName = $dao->getFieldValue('last_name');
$dao = CRM_Core_DAO::executeQuery("SELECT price FROM products WHERE id = %1", array(1 => array($productId, 'Integer'))); $productPrice = $dao->getFieldValue('price');In this example, the getFieldValue method is used to retrieve the value of the "price" field in the "products" database table, using the specified product ID. The method then returns the product price as a string or float value, which can be used elsewhere in the code. In both of these code examples, the package library being used is likely the CiviCRM package library, which is a popular open-source CRM system used by non-profit organizations, charities, and other social sector entities. The CRM_Core_DAO class is one of the core database access classes in the CiviCRM library, used for interacting with database tables and fields to access important data.