### Utilize Database Prefix Function (PHP) Source: https://help.perfexcrm.com/module-basics/index Shows how to use the `db_prefix()` function to dynamically retrieve the database table prefix. This ensures module compatibility even if the user changes the default 'tbl' prefix in Perfex CRM settings. The example includes creating a table with the correct prefix. ```php db->table_exists(db_prefix() . 'goals')) { $CI->db->query('CREATE TABLE `' . db_prefix() . "goals` ( `id` int(11) NOT NULL, `subject` varchar(191) NOT NULL, `description` text NOT NULL, `start_date` date NOT NULL, `end_date` date NOT NULL, `goal_type` int(11) NOT NULL, `contract_type` int(11) NOT NULL DEFAULT '0', `achievement` int(11) NOT NULL, `notify_when_fail` tinyint(1) NOT NULL DEFAULT '1', `notify_when_achieve` tinyint(1) NOT NULL DEFAULT '1', `notified` int(11) NOT NULL DEFAULT '0', `staff_id` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=" . $CI->db->char_set . ';'); } ``` -------------------------------- ### Access CodeIgniter Instance in Module Files (PHP) Source: https://help.perfexcrm.com/module-basics/index Demonstrates how to obtain the CodeIgniter framework instance within module files when not extending base classes. This allows access to CodeIgniter's functionalities like loading helpers and libraries using a variable instead of $this. ```php $CI = &get_instance(); $CI->load->helper('module_name/helper_name'); $CI->load->library('module_name/library_name'); ``` -------------------------------- ### Manage Module Options (PHP) Source: https://help.perfexcrm.com/module-basics/index Provides PHP functions for managing module-specific settings stored in the Perfex CRM 'options' table. Includes `add_option` to create new options, `get_option` to retrieve their values, and `update_option` to modify them. The `update_option` function will create the option if it doesn't exist. ```php add_option($name, $value, $autoload); get_option($option_name); update_option($option_name, $new_value); ``` -------------------------------- ### Define Module Metadata with PHP Block Comment Source: https://help.perfexcrm.com/module-basics/index This snippet shows how to define essential metadata for a Perfex CRM module using a PHP block comment at the top of the module's init file. This metadata includes the module's name, description, version, and minimum required version. Ensure this comment is placed at the very beginning of the init file. ```php add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1); hooks()->add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1); hooks()->do_action($tag, $arg = ''); hooks()->apply_filters($tag, $value, $additionalParams); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.