- $options = _civicrm_api3_get_options_from_params($params, TRUE, 'pledge','get');
- if (empty($options['return'])) {
- $options['return'] = CRM_Pledge_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_PLEDGE);
- }
- else {
- $options['return']['pledge_id'] = 1;
- }
- $newParams = CRM_Contact_BAO_Query::convertFormValues($options['input_params']);
- $query = new CRM_Contact_BAO_Query($newParams, $options['return'], NULL,
- FALSE, FALSE, CRM_Contact_BAO_Query::MODE_PLEDGE
- );
- list($select, $from, $where) = $query->query();
- $sql = "$select $from $where";
- if (!empty($options['sort'])) {
- $sql .= " ORDER BY " . $options['sort'];
- }
- $sql .= " LIMIT " . $options['offset'] . " , " . $options['limit'];
- $dao = CRM_Core_DAO::executeQuery($sql);