5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/SavedSearch.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:c884fe02dfd203d381429f83672e1a9e)
13 * Database access object for the SavedSearch entity.
15 class CRM_Contact_DAO_SavedSearch
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_saved_search';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = FALSE;
41 * Unique name of saved search
48 * Administrative label for search
55 * Submitted form values for this search
62 * Foreign key to civicrm_mapping used for saved search-builder searches.
69 * Foreign key to civicrm_option value table used for saved custom searches.
73 public $search_custom_id;
76 * Entity name for API based search
83 * Parameters for API based search
90 * FK to contact table.
97 * FK to contact table.
104 * Optional date after which the search is not needed
108 public $expires_date;
111 * When the search was created.
115 public $created_date;
118 * When the search was last modified.
122 public $modified_date;
132 public function __construct() {
133 $this->__table
= 'civicrm_saved_search';
134 parent
::__construct();
138 * Returns localized title of this entity.
140 * @param bool $plural
141 * Whether to return the plural version of the title.
143 public static function getEntityTitle($plural = FALSE) {
144 return $plural ?
ts('Saved Searches') : ts('Saved Search');
148 * Returns foreign keys and entity references.
151 * [CRM_Core_Reference_Interface]
153 public static function getReferenceColumns() {
154 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
155 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
156 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
157 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
158 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
159 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
161 return Civi
::$statics[__CLASS__
]['links'];
165 * Returns all the column names of this table
169 public static function &fields() {
170 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
171 Civi
::$statics[__CLASS__
]['fields'] = [
174 'type' => CRM_Utils_Type
::T_INT
,
175 'title' => ts('Saved Search ID'),
176 'description' => ts('Saved Search ID'),
178 'where' => 'civicrm_saved_search.id',
179 'table_name' => 'civicrm_saved_search',
180 'entity' => 'SavedSearch',
181 'bao' => 'CRM_Contact_BAO_SavedSearch',
191 'type' => CRM_Utils_Type
::T_STRING
,
192 'title' => ts('Saved Search Name'),
193 'description' => ts('Unique name of saved search'),
195 'size' => CRM_Utils_Type
::HUGE
,
196 'where' => 'civicrm_saved_search.name',
198 'table_name' => 'civicrm_saved_search',
199 'entity' => 'SavedSearch',
200 'bao' => 'CRM_Contact_BAO_SavedSearch',
209 'type' => CRM_Utils_Type
::T_STRING
,
210 'title' => ts('Saved Search Label'),
211 'description' => ts('Administrative label for search'),
213 'size' => CRM_Utils_Type
::HUGE
,
214 'where' => 'civicrm_saved_search.label',
216 'table_name' => 'civicrm_saved_search',
217 'entity' => 'SavedSearch',
218 'bao' => 'CRM_Contact_BAO_SavedSearch',
226 'name' => 'form_values',
227 'type' => CRM_Utils_Type
::T_TEXT
,
228 'title' => ts('Submitted Form Values'),
229 'description' => ts('Submitted form values for this search'),
231 'where' => 'civicrm_saved_search.form_values',
233 'table_name' => 'civicrm_saved_search',
234 'entity' => 'SavedSearch',
235 'bao' => 'CRM_Contact_BAO_SavedSearch',
237 'serialize' => self
::SERIALIZE_PHP
,
241 'name' => 'mapping_id',
242 'type' => CRM_Utils_Type
::T_INT
,
243 'title' => ts('Mapping ID'),
244 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
245 'where' => 'civicrm_saved_search.mapping_id',
246 'table_name' => 'civicrm_saved_search',
247 'entity' => 'SavedSearch',
248 'bao' => 'CRM_Contact_BAO_SavedSearch',
250 'FKClassName' => 'CRM_Core_DAO_Mapping',
252 'label' => ts("Mapping"),
256 'search_custom_id' => [
257 'name' => 'search_custom_id',
258 'type' => CRM_Utils_Type
::T_INT
,
259 'title' => ts('Option Value ID'),
260 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
261 'where' => 'civicrm_saved_search.search_custom_id',
262 'table_name' => 'civicrm_saved_search',
263 'entity' => 'SavedSearch',
264 'bao' => 'CRM_Contact_BAO_SavedSearch',
269 'name' => 'api_entity',
270 'type' => CRM_Utils_Type
::T_STRING
,
271 'title' => ts('Entity Name'),
272 'description' => ts('Entity name for API based search'),
274 'size' => CRM_Utils_Type
::HUGE
,
275 'where' => 'civicrm_saved_search.api_entity',
276 'table_name' => 'civicrm_saved_search',
277 'entity' => 'SavedSearch',
278 'bao' => 'CRM_Contact_BAO_SavedSearch',
283 'name' => 'api_params',
284 'type' => CRM_Utils_Type
::T_TEXT
,
285 'title' => ts('API Parameters'),
286 'description' => ts('Parameters for API based search'),
287 'where' => 'civicrm_saved_search.api_params',
288 'table_name' => 'civicrm_saved_search',
289 'entity' => 'SavedSearch',
290 'bao' => 'CRM_Contact_BAO_SavedSearch',
292 'serialize' => self
::SERIALIZE_JSON
,
296 'name' => 'created_id',
297 'type' => CRM_Utils_Type
::T_INT
,
298 'title' => ts('Created By Contact ID'),
299 'description' => ts('FK to contact table.'),
300 'where' => 'civicrm_saved_search.created_id',
301 'table_name' => 'civicrm_saved_search',
302 'entity' => 'SavedSearch',
303 'bao' => 'CRM_Contact_BAO_SavedSearch',
305 'FKClassName' => 'CRM_Contact_DAO_Contact',
307 'label' => ts("Created By"),
313 'name' => 'modified_id',
314 'type' => CRM_Utils_Type
::T_INT
,
315 'title' => ts('Modified By Contact ID'),
316 'description' => ts('FK to contact table.'),
317 'where' => 'civicrm_saved_search.modified_id',
318 'table_name' => 'civicrm_saved_search',
319 'entity' => 'SavedSearch',
320 'bao' => 'CRM_Contact_BAO_SavedSearch',
322 'FKClassName' => 'CRM_Contact_DAO_Contact',
324 'label' => ts("Modified By"),
330 'name' => 'expires_date',
331 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
332 'title' => ts('Search Expiry Date'),
333 'description' => ts('Optional date after which the search is not needed'),
335 'where' => 'civicrm_saved_search.expires_date',
336 'table_name' => 'civicrm_saved_search',
337 'entity' => 'SavedSearch',
338 'bao' => 'CRM_Contact_BAO_SavedSearch',
343 'name' => 'created_date',
344 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
345 'title' => ts('Created Date'),
346 'description' => ts('When the search was created.'),
348 'where' => 'civicrm_saved_search.created_date',
349 'default' => 'CURRENT_TIMESTAMP',
350 'table_name' => 'civicrm_saved_search',
351 'entity' => 'SavedSearch',
352 'bao' => 'CRM_Contact_BAO_SavedSearch',
358 'name' => 'modified_date',
359 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
360 'title' => ts('Modified Date'),
361 'description' => ts('When the search was last modified.'),
363 'where' => 'civicrm_saved_search.modified_date',
364 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
365 'table_name' => 'civicrm_saved_search',
366 'entity' => 'SavedSearch',
367 'bao' => 'CRM_Contact_BAO_SavedSearch',
373 'name' => 'description',
374 'type' => CRM_Utils_Type
::T_TEXT
,
375 'title' => ts('Saved Search Description'),
378 'where' => 'civicrm_saved_search.description',
379 'table_name' => 'civicrm_saved_search',
380 'entity' => 'SavedSearch',
381 'bao' => 'CRM_Contact_BAO_SavedSearch',
384 'type' => 'TextArea',
389 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
391 return Civi
::$statics[__CLASS__
]['fields'];
395 * Return a mapping from field-name to the corresponding key (as used in fields()).
398 * Array(string $name => string $uniqueName).
400 public static function &fieldKeys() {
401 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
402 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
404 return Civi
::$statics[__CLASS__
]['fieldKeys'];
408 * Returns the names of this table
412 public static function getTableName() {
413 return self
::$_tableName;
417 * Returns if this table needs to be logged
421 public function getLog() {
426 * Returns the list of fields that can be imported
428 * @param bool $prefix
432 public static function &import($prefix = FALSE) {
433 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'saved_search', $prefix, []);
438 * Returns the list of fields that can be exported
440 * @param bool $prefix
444 public static function &export($prefix = FALSE) {
445 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'saved_search', $prefix, []);
450 * Returns the list of indices
452 * @param bool $localize
456 public static function indices($localize = TRUE) {
463 'localizable' => FALSE,
465 'sig' => 'civicrm_saved_search::1::name',
468 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;