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:935938d45a416234d369d2db97a08311)
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;
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
43 * Unique name of saved search
46 * (SQL type: varchar(255))
47 * Note that values will be retrieved from the database as a string.
52 * Administrative label for search
55 * (SQL type: varchar(255))
56 * Note that values will be retrieved from the database as a string.
61 * Submitted form values for this search
65 * Note that values will be retrieved from the database as a string.
70 * Foreign key to civicrm_mapping used for saved search-builder searches.
72 * @var int|string|null
73 * (SQL type: int unsigned)
74 * Note that values will be retrieved from the database as a string.
79 * Foreign key to civicrm_option value table used for saved custom searches.
81 * @var int|string|null
82 * (SQL type: int unsigned)
83 * Note that values will be retrieved from the database as a string.
85 public $search_custom_id;
88 * Entity name for API based search
91 * (SQL type: varchar(255))
92 * Note that values will be retrieved from the database as a string.
97 * Parameters for API based search
101 * Note that values will be retrieved from the database as a string.
106 * FK to contact table.
108 * @var int|string|null
109 * (SQL type: int unsigned)
110 * Note that values will be retrieved from the database as a string.
115 * FK to contact table.
117 * @var int|string|null
118 * (SQL type: int unsigned)
119 * Note that values will be retrieved from the database as a string.
124 * Optional date after which the search is not needed
127 * (SQL type: timestamp)
128 * Note that values will be retrieved from the database as a string.
130 public $expires_date;
133 * When the search was created.
136 * (SQL type: timestamp)
137 * Note that values will be retrieved from the database as a string.
139 public $created_date;
142 * When the search was last modified.
145 * (SQL type: timestamp)
146 * Note that values will be retrieved from the database as a string.
148 public $modified_date;
153 * Note that values will be retrieved from the database as a string.
160 public function __construct() {
161 $this->__table
= 'civicrm_saved_search';
162 parent
::__construct();
166 * Returns localized title of this entity.
168 * @param bool $plural
169 * Whether to return the plural version of the title.
171 public static function getEntityTitle($plural = FALSE) {
172 return $plural ?
ts('Saved Searches') : ts('Saved Search');
176 * Returns foreign keys and entity references.
179 * [CRM_Core_Reference_Interface]
181 public static function getReferenceColumns() {
182 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
183 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
184 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
185 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
186 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
187 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
189 return Civi
::$statics[__CLASS__
]['links'];
193 * Returns all the column names of this table
197 public static function &fields() {
198 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
199 Civi
::$statics[__CLASS__
]['fields'] = [
202 'type' => CRM_Utils_Type
::T_INT
,
203 'title' => ts('Saved Search ID'),
204 'description' => ts('Saved Search ID'),
206 'where' => 'civicrm_saved_search.id',
207 'table_name' => 'civicrm_saved_search',
208 'entity' => 'SavedSearch',
209 'bao' => 'CRM_Contact_BAO_SavedSearch',
219 'type' => CRM_Utils_Type
::T_STRING
,
220 'title' => ts('Saved Search Name'),
221 'description' => ts('Unique name of saved search'),
223 'size' => CRM_Utils_Type
::HUGE
,
224 'where' => 'civicrm_saved_search.name',
226 'table_name' => 'civicrm_saved_search',
227 'entity' => 'SavedSearch',
228 'bao' => 'CRM_Contact_BAO_SavedSearch',
237 'type' => CRM_Utils_Type
::T_STRING
,
238 'title' => ts('Saved Search Label'),
239 'description' => ts('Administrative label for search'),
241 'size' => CRM_Utils_Type
::HUGE
,
242 'where' => 'civicrm_saved_search.label',
244 'table_name' => 'civicrm_saved_search',
245 'entity' => 'SavedSearch',
246 'bao' => 'CRM_Contact_BAO_SavedSearch',
250 'label' => ts("Label"),
255 'name' => 'form_values',
256 'type' => CRM_Utils_Type
::T_TEXT
,
257 'title' => ts('Submitted Form Values'),
258 'description' => ts('Submitted form values for this search'),
260 'where' => 'civicrm_saved_search.form_values',
262 'table_name' => 'civicrm_saved_search',
263 'entity' => 'SavedSearch',
264 'bao' => 'CRM_Contact_BAO_SavedSearch',
266 'serialize' => self
::SERIALIZE_PHP
,
270 'name' => 'mapping_id',
271 'type' => CRM_Utils_Type
::T_INT
,
272 'title' => ts('Mapping ID'),
273 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
274 'where' => 'civicrm_saved_search.mapping_id',
275 'table_name' => 'civicrm_saved_search',
276 'entity' => 'SavedSearch',
277 'bao' => 'CRM_Contact_BAO_SavedSearch',
279 'FKClassName' => 'CRM_Core_DAO_Mapping',
281 'label' => ts("Mapping"),
285 'search_custom_id' => [
286 'name' => 'search_custom_id',
287 'type' => CRM_Utils_Type
::T_INT
,
288 'title' => ts('Option Value ID'),
289 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
290 'where' => 'civicrm_saved_search.search_custom_id',
291 'table_name' => 'civicrm_saved_search',
292 'entity' => 'SavedSearch',
293 'bao' => 'CRM_Contact_BAO_SavedSearch',
298 'name' => 'api_entity',
299 'type' => CRM_Utils_Type
::T_STRING
,
300 'title' => ts('Entity Name'),
301 'description' => ts('Entity name for API based search'),
303 'size' => CRM_Utils_Type
::HUGE
,
304 'where' => 'civicrm_saved_search.api_entity',
305 'table_name' => 'civicrm_saved_search',
306 'entity' => 'SavedSearch',
307 'bao' => 'CRM_Contact_BAO_SavedSearch',
309 'pseudoconstant' => [
310 'callback' => 'CRM_Contact_BAO_SavedSearch::getApiEntityOptions',
315 'name' => 'api_params',
316 'type' => CRM_Utils_Type
::T_TEXT
,
317 'title' => ts('API Parameters'),
318 'description' => ts('Parameters for API based search'),
319 'where' => 'civicrm_saved_search.api_params',
320 'table_name' => 'civicrm_saved_search',
321 'entity' => 'SavedSearch',
322 'bao' => 'CRM_Contact_BAO_SavedSearch',
324 'serialize' => self
::SERIALIZE_JSON
,
328 'name' => 'created_id',
329 'type' => CRM_Utils_Type
::T_INT
,
330 'title' => ts('Created By Contact ID'),
331 'description' => ts('FK to contact table.'),
332 'where' => 'civicrm_saved_search.created_id',
333 'table_name' => 'civicrm_saved_search',
334 'entity' => 'SavedSearch',
335 'bao' => 'CRM_Contact_BAO_SavedSearch',
337 'FKClassName' => 'CRM_Contact_DAO_Contact',
339 'label' => ts("Created By"),
345 'name' => 'modified_id',
346 'type' => CRM_Utils_Type
::T_INT
,
347 'title' => ts('Modified By Contact ID'),
348 'description' => ts('FK to contact table.'),
349 'where' => 'civicrm_saved_search.modified_id',
350 'table_name' => 'civicrm_saved_search',
351 'entity' => 'SavedSearch',
352 'bao' => 'CRM_Contact_BAO_SavedSearch',
354 'FKClassName' => 'CRM_Contact_DAO_Contact',
356 'label' => ts("Modified By"),
362 'name' => 'expires_date',
363 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
364 'title' => ts('Search Expiry Date'),
365 'description' => ts('Optional date after which the search is not needed'),
367 'where' => 'civicrm_saved_search.expires_date',
368 'table_name' => 'civicrm_saved_search',
369 'entity' => 'SavedSearch',
370 'bao' => 'CRM_Contact_BAO_SavedSearch',
375 'name' => 'created_date',
376 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
377 'title' => ts('Created Date'),
378 'description' => ts('When the search was created.'),
380 'where' => 'civicrm_saved_search.created_date',
381 'default' => 'CURRENT_TIMESTAMP',
382 'table_name' => 'civicrm_saved_search',
383 'entity' => 'SavedSearch',
384 'bao' => 'CRM_Contact_BAO_SavedSearch',
390 'name' => 'modified_date',
391 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
392 'title' => ts('Modified Date'),
393 'description' => ts('When the search was last modified.'),
395 'where' => 'civicrm_saved_search.modified_date',
396 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
397 'table_name' => 'civicrm_saved_search',
398 'entity' => 'SavedSearch',
399 'bao' => 'CRM_Contact_BAO_SavedSearch',
405 'name' => 'description',
406 'type' => CRM_Utils_Type
::T_TEXT
,
407 'title' => ts('Saved Search Description'),
410 'where' => 'civicrm_saved_search.description',
411 'table_name' => 'civicrm_saved_search',
412 'entity' => 'SavedSearch',
413 'bao' => 'CRM_Contact_BAO_SavedSearch',
416 'type' => 'TextArea',
421 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
423 return Civi
::$statics[__CLASS__
]['fields'];
427 * Return a mapping from field-name to the corresponding key (as used in fields()).
430 * Array(string $name => string $uniqueName).
432 public static function &fieldKeys() {
433 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
434 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
436 return Civi
::$statics[__CLASS__
]['fieldKeys'];
440 * Returns the names of this table
444 public static function getTableName() {
445 return self
::$_tableName;
449 * Returns if this table needs to be logged
453 public function getLog() {
458 * Returns the list of fields that can be imported
460 * @param bool $prefix
464 public static function &import($prefix = FALSE) {
465 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'saved_search', $prefix, []);
470 * Returns the list of fields that can be exported
472 * @param bool $prefix
476 public static function &export($prefix = FALSE) {
477 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'saved_search', $prefix, []);
482 * Returns the list of indices
484 * @param bool $localize
488 public static function indices($localize = TRUE) {
495 'localizable' => FALSE,
497 'sig' => 'civicrm_saved_search::1::name',
500 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;