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:1b324e028960b1c8fd94ecdc973a6fdc)
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 * Icon associated with this entity.
31 public static $_icon = 'fa-search-plus';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = FALSE;
43 * @var int|string|null
44 * (SQL type: int unsigned)
45 * Note that values will be retrieved from the database as a string.
50 * Unique name of saved search
53 * (SQL type: varchar(255))
54 * Note that values will be retrieved from the database as a string.
59 * Administrative label for search
62 * (SQL type: varchar(255))
63 * Note that values will be retrieved from the database as a string.
68 * Submitted form values for this search
72 * Note that values will be retrieved from the database as a string.
77 * Foreign key to civicrm_mapping used for saved search-builder searches.
79 * @var int|string|null
80 * (SQL type: int unsigned)
81 * Note that values will be retrieved from the database as a string.
86 * Foreign key to civicrm_option value table used for saved custom searches.
88 * @var int|string|null
89 * (SQL type: int unsigned)
90 * Note that values will be retrieved from the database as a string.
92 public $search_custom_id;
95 * Entity name for API based search
98 * (SQL type: varchar(255))
99 * Note that values will be retrieved from the database as a string.
104 * Parameters for API based search
108 * Note that values will be retrieved from the database as a string.
113 * FK to contact table.
115 * @var int|string|null
116 * (SQL type: int unsigned)
117 * Note that values will be retrieved from the database as a string.
122 * FK to contact table.
124 * @var int|string|null
125 * (SQL type: int unsigned)
126 * Note that values will be retrieved from the database as a string.
131 * Optional date after which the search is not needed
134 * (SQL type: timestamp)
135 * Note that values will be retrieved from the database as a string.
137 public $expires_date;
140 * When the search was created.
143 * (SQL type: timestamp)
144 * Note that values will be retrieved from the database as a string.
146 public $created_date;
149 * When the search was last modified.
152 * (SQL type: timestamp)
153 * Note that values will be retrieved from the database as a string.
155 public $modified_date;
160 * Note that values will be retrieved from the database as a string.
167 public function __construct() {
168 $this->__table
= 'civicrm_saved_search';
169 parent
::__construct();
173 * Returns localized title of this entity.
175 * @param bool $plural
176 * Whether to return the plural version of the title.
178 public static function getEntityTitle($plural = FALSE) {
179 return $plural ?
ts('Saved Searches') : ts('Saved Search');
183 * Returns foreign keys and entity references.
186 * [CRM_Core_Reference_Interface]
188 public static function getReferenceColumns() {
189 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
190 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
191 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
192 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
193 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
194 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
196 return Civi
::$statics[__CLASS__
]['links'];
200 * Returns all the column names of this table
204 public static function &fields() {
205 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
206 Civi
::$statics[__CLASS__
]['fields'] = [
209 'type' => CRM_Utils_Type
::T_INT
,
210 'title' => ts('Saved Search ID'),
211 'description' => ts('Saved Search ID'),
213 'where' => 'civicrm_saved_search.id',
214 'table_name' => 'civicrm_saved_search',
215 'entity' => 'SavedSearch',
216 'bao' => 'CRM_Contact_BAO_SavedSearch',
226 'type' => CRM_Utils_Type
::T_STRING
,
227 'title' => ts('Saved Search Name'),
228 'description' => ts('Unique name of saved search'),
230 'size' => CRM_Utils_Type
::HUGE
,
231 'where' => 'civicrm_saved_search.name',
233 'table_name' => 'civicrm_saved_search',
234 'entity' => 'SavedSearch',
235 'bao' => 'CRM_Contact_BAO_SavedSearch',
244 'type' => CRM_Utils_Type
::T_STRING
,
245 'title' => ts('Saved Search Label'),
246 'description' => ts('Administrative label for search'),
248 'size' => CRM_Utils_Type
::HUGE
,
249 'where' => 'civicrm_saved_search.label',
251 'table_name' => 'civicrm_saved_search',
252 'entity' => 'SavedSearch',
253 'bao' => 'CRM_Contact_BAO_SavedSearch',
257 'label' => ts("Label"),
262 'name' => 'form_values',
263 'type' => CRM_Utils_Type
::T_TEXT
,
264 'title' => ts('Submitted Form Values'),
265 'description' => ts('Submitted form values for this search'),
267 'where' => 'civicrm_saved_search.form_values',
269 'table_name' => 'civicrm_saved_search',
270 'entity' => 'SavedSearch',
271 'bao' => 'CRM_Contact_BAO_SavedSearch',
273 'serialize' => self
::SERIALIZE_PHP
,
277 'name' => 'mapping_id',
278 'type' => CRM_Utils_Type
::T_INT
,
279 'title' => ts('Mapping ID'),
280 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
281 'where' => 'civicrm_saved_search.mapping_id',
282 'table_name' => 'civicrm_saved_search',
283 'entity' => 'SavedSearch',
284 'bao' => 'CRM_Contact_BAO_SavedSearch',
286 'FKClassName' => 'CRM_Core_DAO_Mapping',
288 'label' => ts("Mapping"),
292 'search_custom_id' => [
293 'name' => 'search_custom_id',
294 'type' => CRM_Utils_Type
::T_INT
,
295 'title' => ts('Option Value ID'),
296 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
297 'where' => 'civicrm_saved_search.search_custom_id',
298 'table_name' => 'civicrm_saved_search',
299 'entity' => 'SavedSearch',
300 'bao' => 'CRM_Contact_BAO_SavedSearch',
305 'name' => 'api_entity',
306 'type' => CRM_Utils_Type
::T_STRING
,
307 'title' => ts('Entity Name'),
308 'description' => ts('Entity name for API based search'),
310 'size' => CRM_Utils_Type
::HUGE
,
311 'where' => 'civicrm_saved_search.api_entity',
312 'table_name' => 'civicrm_saved_search',
313 'entity' => 'SavedSearch',
314 'bao' => 'CRM_Contact_BAO_SavedSearch',
316 'pseudoconstant' => [
317 'callback' => 'CRM_Contact_BAO_SavedSearch::getApiEntityOptions',
322 'name' => 'api_params',
323 'type' => CRM_Utils_Type
::T_TEXT
,
324 'title' => ts('API Parameters'),
325 'description' => ts('Parameters for API based search'),
326 'where' => 'civicrm_saved_search.api_params',
327 'table_name' => 'civicrm_saved_search',
328 'entity' => 'SavedSearch',
329 'bao' => 'CRM_Contact_BAO_SavedSearch',
331 'serialize' => self
::SERIALIZE_JSON
,
335 'name' => 'created_id',
336 'type' => CRM_Utils_Type
::T_INT
,
337 'title' => ts('Created By Contact ID'),
338 'description' => ts('FK to contact table.'),
339 'where' => 'civicrm_saved_search.created_id',
340 'table_name' => 'civicrm_saved_search',
341 'entity' => 'SavedSearch',
342 'bao' => 'CRM_Contact_BAO_SavedSearch',
344 'FKClassName' => 'CRM_Contact_DAO_Contact',
346 'label' => ts("Created By"),
352 'name' => 'modified_id',
353 'type' => CRM_Utils_Type
::T_INT
,
354 'title' => ts('Modified By Contact ID'),
355 'description' => ts('FK to contact table.'),
356 'where' => 'civicrm_saved_search.modified_id',
357 'table_name' => 'civicrm_saved_search',
358 'entity' => 'SavedSearch',
359 'bao' => 'CRM_Contact_BAO_SavedSearch',
361 'FKClassName' => 'CRM_Contact_DAO_Contact',
363 'label' => ts("Modified By"),
369 'name' => 'expires_date',
370 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
371 'title' => ts('Search Expiry Date'),
372 'description' => ts('Optional date after which the search is not needed'),
374 'where' => 'civicrm_saved_search.expires_date',
375 'table_name' => 'civicrm_saved_search',
376 'entity' => 'SavedSearch',
377 'bao' => 'CRM_Contact_BAO_SavedSearch',
382 'name' => 'created_date',
383 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
384 'title' => ts('Created Date'),
385 'description' => ts('When the search was created.'),
387 'where' => 'civicrm_saved_search.created_date',
388 'default' => 'CURRENT_TIMESTAMP',
389 'table_name' => 'civicrm_saved_search',
390 'entity' => 'SavedSearch',
391 'bao' => 'CRM_Contact_BAO_SavedSearch',
397 'name' => 'modified_date',
398 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
399 'title' => ts('Modified Date'),
400 'description' => ts('When the search was last modified.'),
402 'where' => 'civicrm_saved_search.modified_date',
403 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
404 'table_name' => 'civicrm_saved_search',
405 'entity' => 'SavedSearch',
406 'bao' => 'CRM_Contact_BAO_SavedSearch',
412 'name' => 'description',
413 'type' => CRM_Utils_Type
::T_TEXT
,
414 'title' => ts('Saved Search Description'),
417 'where' => 'civicrm_saved_search.description',
418 'table_name' => 'civicrm_saved_search',
419 'entity' => 'SavedSearch',
420 'bao' => 'CRM_Contact_BAO_SavedSearch',
423 'type' => 'TextArea',
428 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
430 return Civi
::$statics[__CLASS__
]['fields'];
434 * Return a mapping from field-name to the corresponding key (as used in fields()).
437 * Array(string $name => string $uniqueName).
439 public static function &fieldKeys() {
440 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
441 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
443 return Civi
::$statics[__CLASS__
]['fieldKeys'];
447 * Returns the names of this table
451 public static function getTableName() {
452 return self
::$_tableName;
456 * Returns if this table needs to be logged
460 public function getLog() {
465 * Returns the list of fields that can be imported
467 * @param bool $prefix
471 public static function &import($prefix = FALSE) {
472 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'saved_search', $prefix, []);
477 * Returns the list of fields that can be exported
479 * @param bool $prefix
483 public static function &export($prefix = FALSE) {
484 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'saved_search', $prefix, []);
489 * Returns the list of indices
491 * @param bool $localize
495 public static function indices($localize = TRUE) {
502 'localizable' => FALSE,
504 'sig' => 'civicrm_saved_search::1::name',
507 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;