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:432bca89c164c512fa77945f8958e60d)
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;
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
43 * Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.
45 * @var int|string|null
46 * (SQL type: int unsigned)
47 * Note that values will be retrieved from the database as a string.
52 * mime type of the document
55 * (SQL type: varchar(255))
56 * Note that values will be retrieved from the database as a string.
61 * uri of the file on disk
64 * (SQL type: varchar(255))
65 * Note that values will be retrieved from the database as a string.
70 * contents of the document
73 * (SQL type: mediumblob)
74 * Note that values will be retrieved from the database as a string.
79 * Additional descriptive text regarding this attachment (optional).
82 * (SQL type: varchar(255))
83 * Note that values will be retrieved from the database as a string.
88 * Date and time that this attachment was uploaded or written to server.
91 * (SQL type: datetime)
92 * Note that values will be retrieved from the database as a string.
97 * FK to civicrm_contact, who uploaded this file
99 * @var int|string|null
100 * (SQL type: int unsigned)
101 * Note that values will be retrieved from the database as a string.
108 public function __construct() {
109 $this->__table
= 'civicrm_file';
110 parent
::__construct();
114 * Returns localized title of this entity.
116 * @param bool $plural
117 * Whether to return the plural version of the title.
119 public static function getEntityTitle($plural = FALSE) {
120 return $plural ?
ts('Files') : ts('File');
124 * Returns foreign keys and entity references.
127 * [CRM_Core_Reference_Interface]
129 public static function getReferenceColumns() {
130 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
131 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
132 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
133 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
135 return Civi
::$statics[__CLASS__
]['links'];
139 * Returns all the column names of this table
143 public static function &fields() {
144 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
145 Civi
::$statics[__CLASS__
]['fields'] = [
148 'type' => CRM_Utils_Type
::T_INT
,
149 'title' => ts('File ID'),
150 'description' => ts('Unique ID'),
152 'where' => 'civicrm_file.id',
153 'table_name' => 'civicrm_file',
155 'bao' => 'CRM_Core_BAO_File',
164 'name' => 'file_type_id',
165 'type' => CRM_Utils_Type
::T_INT
,
166 'title' => ts('File Type'),
167 'description' => ts('Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.'),
168 'where' => 'civicrm_file.file_type_id',
169 'table_name' => 'civicrm_file',
171 'bao' => 'CRM_Core_BAO_File',
176 'name' => 'mime_type',
177 'type' => CRM_Utils_Type
::T_STRING
,
178 'title' => ts('Mime Type'),
179 'description' => ts('mime type of the document'),
181 'size' => CRM_Utils_Type
::HUGE
,
182 'where' => 'civicrm_file.mime_type',
183 'table_name' => 'civicrm_file',
185 'bao' => 'CRM_Core_BAO_File',
191 'type' => CRM_Utils_Type
::T_STRING
,
192 'title' => ts('Path'),
193 'description' => ts('uri of the file on disk'),
195 'size' => CRM_Utils_Type
::HUGE
,
196 'where' => 'civicrm_file.uri',
197 'table_name' => 'civicrm_file',
199 'bao' => 'CRM_Core_BAO_File',
204 'name' => 'document',
205 'type' => CRM_Utils_Type
::T_MEDIUMBLOB
,
206 'title' => ts('File Contents'),
207 'description' => ts('contents of the document'),
208 'where' => 'civicrm_file.document',
209 'table_name' => 'civicrm_file',
211 'bao' => 'CRM_Core_BAO_File',
216 'name' => 'description',
217 'type' => CRM_Utils_Type
::T_STRING
,
218 'title' => ts('File Description'),
219 'description' => ts('Additional descriptive text regarding this attachment (optional).'),
221 'size' => CRM_Utils_Type
::HUGE
,
222 'where' => 'civicrm_file.description',
223 'table_name' => 'civicrm_file',
225 'bao' => 'CRM_Core_BAO_File',
230 'name' => 'upload_date',
231 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
232 'title' => ts('File Upload Date'),
233 'description' => ts('Date and time that this attachment was uploaded or written to server.'),
234 'where' => 'civicrm_file.upload_date',
235 'table_name' => 'civicrm_file',
237 'bao' => 'CRM_Core_BAO_File',
242 'name' => 'created_id',
243 'type' => CRM_Utils_Type
::T_INT
,
244 'title' => ts('Created By Contact ID'),
245 'description' => ts('FK to civicrm_contact, who uploaded this file'),
246 'where' => 'civicrm_file.created_id',
247 'table_name' => 'civicrm_file',
249 'bao' => 'CRM_Core_BAO_File',
251 'FKClassName' => 'CRM_Contact_DAO_Contact',
253 'label' => ts("Created By"),
258 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
260 return Civi
::$statics[__CLASS__
]['fields'];
264 * Return a mapping from field-name to the corresponding key (as used in fields()).
267 * Array(string $name => string $uniqueName).
269 public static function &fieldKeys() {
270 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
271 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
273 return Civi
::$statics[__CLASS__
]['fieldKeys'];
277 * Returns the names of this table
281 public static function getTableName() {
282 return self
::$_tableName;
286 * Returns if this table needs to be logged
290 public function getLog() {
295 * Returns the list of fields that can be imported
297 * @param bool $prefix
301 public static function &import($prefix = FALSE) {
302 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'file', $prefix, []);
307 * Returns the list of fields that can be exported
309 * @param bool $prefix
313 public static function &export($prefix = FALSE) {
314 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'file', $prefix, []);
319 * Returns the list of indices
321 * @param bool $localize
325 public static function indices($localize = TRUE) {
327 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;