/** * Insert a record based on a DAO. * * @param \CRM_Core_DAO $dao * @return \CRM_Utils_SQL_Insert * @throws \CRM_Core_Exception */ public static function dao(CRM_Core_DAO $dao) { $table = CRM_Core_DAO::getLocaleTableName($dao->getTableName()); $row = array(); foreach ((array) $dao as $key => $value) { if ($value === 'null') { $value = NULL; // Blerg!!! } // Skip '_foobar' and '{\u00}*_options' and 'N'. if (preg_match('/[a-zA-Z]/', $key[0]) && $key !== 'N') { $row[$key] = $value; } } return self::into($table)->row($row); }
/** * @param CRM_Core_DAO $dao * * @return mixed */ public static function postSave(&$dao) { $hookName = 'civicrm_postSave_' . $dao->getTableName(); return self::singleton()->invoke(1, $dao, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, $hookName); }