5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/File.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:aa0883a815a43dd250612348f3ec470e)
13 * Database access object for the File entity.
15 class CRM_Core_DAO_File
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.5';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_file';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
41 * Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.
48 * mime type of the document
55 * uri of the file on disk
62 * contents of the document
69 * Additional descriptive text regarding this attachment (optional).
76 * Date and time that this attachment was uploaded or written to server.
83 * FK to civicrm_contact, who uploaded this file
92 public function __construct() {
93 $this->__table
= 'civicrm_file';
94 parent
::__construct();
98 * Returns localized title of this entity.
100 public static function getEntityTitle() {
105 * Returns foreign keys and entity references.
108 * [CRM_Core_Reference_Interface]
110 public static function getReferenceColumns() {
111 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
112 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
113 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
114 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
116 return Civi
::$statics[__CLASS__
]['links'];
120 * Returns all the column names of this table
124 public static function &fields() {
125 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
126 Civi
::$statics[__CLASS__
]['fields'] = [
129 'type' => CRM_Utils_Type
::T_INT
,
130 'title' => ts('File ID'),
131 'description' => ts('Unique ID'),
133 'where' => 'civicrm_file.id',
134 'table_name' => 'civicrm_file',
136 'bao' => 'CRM_Core_BAO_File',
141 'name' => 'file_type_id',
142 'type' => CRM_Utils_Type
::T_INT
,
143 'title' => ts('File Type'),
144 'description' => ts('Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.'),
145 'where' => 'civicrm_file.file_type_id',
146 'table_name' => 'civicrm_file',
148 'bao' => 'CRM_Core_BAO_File',
153 'name' => 'mime_type',
154 'type' => CRM_Utils_Type
::T_STRING
,
155 'title' => ts('Mime Type'),
156 'description' => ts('mime type of the document'),
158 'size' => CRM_Utils_Type
::HUGE
,
159 'where' => 'civicrm_file.mime_type',
160 'table_name' => 'civicrm_file',
162 'bao' => 'CRM_Core_BAO_File',
168 'type' => CRM_Utils_Type
::T_STRING
,
169 'title' => ts('Path'),
170 'description' => ts('uri of the file on disk'),
172 'size' => CRM_Utils_Type
::HUGE
,
173 'where' => 'civicrm_file.uri',
174 'table_name' => 'civicrm_file',
176 'bao' => 'CRM_Core_BAO_File',
181 'name' => 'document',
182 'type' => CRM_Utils_Type
::T_MEDIUMBLOB
,
183 'title' => ts('File Contents'),
184 'description' => ts('contents of the document'),
185 'where' => 'civicrm_file.document',
186 'table_name' => 'civicrm_file',
188 'bao' => 'CRM_Core_BAO_File',
193 'name' => 'description',
194 'type' => CRM_Utils_Type
::T_STRING
,
195 'title' => ts('File Description'),
196 'description' => ts('Additional descriptive text regarding this attachment (optional).'),
198 'size' => CRM_Utils_Type
::HUGE
,
199 'where' => 'civicrm_file.description',
200 'table_name' => 'civicrm_file',
202 'bao' => 'CRM_Core_BAO_File',
207 'name' => 'upload_date',
208 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
209 'title' => ts('File Upload Date'),
210 'description' => ts('Date and time that this attachment was uploaded or written to server.'),
211 'where' => 'civicrm_file.upload_date',
212 'table_name' => 'civicrm_file',
214 'bao' => 'CRM_Core_BAO_File',
219 'name' => 'created_id',
220 'type' => CRM_Utils_Type
::T_INT
,
221 'title' => ts('Created By Contact ID'),
222 'description' => ts('FK to civicrm_contact, who uploaded this file'),
223 'where' => 'civicrm_file.created_id',
224 'table_name' => 'civicrm_file',
226 'bao' => 'CRM_Core_BAO_File',
228 'FKClassName' => 'CRM_Contact_DAO_Contact',
232 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
234 return Civi
::$statics[__CLASS__
]['fields'];
238 * Return a mapping from field-name to the corresponding key (as used in fields()).
241 * Array(string $name => string $uniqueName).
243 public static function &fieldKeys() {
244 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
245 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
247 return Civi
::$statics[__CLASS__
]['fieldKeys'];
251 * Returns the names of this table
255 public static function getTableName() {
256 return self
::$_tableName;
260 * Returns if this table needs to be logged
264 public function getLog() {
269 * Returns the list of fields that can be imported
271 * @param bool $prefix
275 public static function &import($prefix = FALSE) {
276 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'file', $prefix, []);
281 * Returns the list of fields that can be exported
283 * @param bool $prefix
287 public static function &export($prefix = FALSE) {
288 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'file', $prefix, []);
293 * Returns the list of indices
295 * @param bool $localize
299 public static function indices($localize = TRUE) {
301 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;