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:dd8a70727f67481339dd514fdca6aae5)
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 * @param bool $plural
101 * Whether to return the plural version of the title.
103 public static function getEntityTitle($plural = FALSE) {
104 return $plural ?
ts('Files') : ts('File');
108 * Returns foreign keys and entity references.
111 * [CRM_Core_Reference_Interface]
113 public static function getReferenceColumns() {
114 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
115 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
116 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
117 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
119 return Civi
::$statics[__CLASS__
]['links'];
123 * Returns all the column names of this table
127 public static function &fields() {
128 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
129 Civi
::$statics[__CLASS__
]['fields'] = [
132 'type' => CRM_Utils_Type
::T_INT
,
133 'title' => ts('File ID'),
134 'description' => ts('Unique ID'),
136 'where' => 'civicrm_file.id',
137 'table_name' => 'civicrm_file',
139 'bao' => 'CRM_Core_BAO_File',
144 'name' => 'file_type_id',
145 'type' => CRM_Utils_Type
::T_INT
,
146 'title' => ts('File Type'),
147 'description' => ts('Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.'),
148 'where' => 'civicrm_file.file_type_id',
149 'table_name' => 'civicrm_file',
151 'bao' => 'CRM_Core_BAO_File',
156 'name' => 'mime_type',
157 'type' => CRM_Utils_Type
::T_STRING
,
158 'title' => ts('Mime Type'),
159 'description' => ts('mime type of the document'),
161 'size' => CRM_Utils_Type
::HUGE
,
162 'where' => 'civicrm_file.mime_type',
163 'table_name' => 'civicrm_file',
165 'bao' => 'CRM_Core_BAO_File',
171 'type' => CRM_Utils_Type
::T_STRING
,
172 'title' => ts('Path'),
173 'description' => ts('uri of the file on disk'),
175 'size' => CRM_Utils_Type
::HUGE
,
176 'where' => 'civicrm_file.uri',
177 'table_name' => 'civicrm_file',
179 'bao' => 'CRM_Core_BAO_File',
184 'name' => 'document',
185 'type' => CRM_Utils_Type
::T_MEDIUMBLOB
,
186 'title' => ts('File Contents'),
187 'description' => ts('contents of the document'),
188 'where' => 'civicrm_file.document',
189 'table_name' => 'civicrm_file',
191 'bao' => 'CRM_Core_BAO_File',
196 'name' => 'description',
197 'type' => CRM_Utils_Type
::T_STRING
,
198 'title' => ts('File Description'),
199 'description' => ts('Additional descriptive text regarding this attachment (optional).'),
201 'size' => CRM_Utils_Type
::HUGE
,
202 'where' => 'civicrm_file.description',
203 'table_name' => 'civicrm_file',
205 'bao' => 'CRM_Core_BAO_File',
210 'name' => 'upload_date',
211 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
212 'title' => ts('File Upload Date'),
213 'description' => ts('Date and time that this attachment was uploaded or written to server.'),
214 'where' => 'civicrm_file.upload_date',
215 'table_name' => 'civicrm_file',
217 'bao' => 'CRM_Core_BAO_File',
222 'name' => 'created_id',
223 'type' => CRM_Utils_Type
::T_INT
,
224 'title' => ts('Created By Contact ID'),
225 'description' => ts('FK to civicrm_contact, who uploaded this file'),
226 'where' => 'civicrm_file.created_id',
227 'table_name' => 'civicrm_file',
229 'bao' => 'CRM_Core_BAO_File',
231 'FKClassName' => 'CRM_Contact_DAO_Contact',
235 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
237 return Civi
::$statics[__CLASS__
]['fields'];
241 * Return a mapping from field-name to the corresponding key (as used in fields()).
244 * Array(string $name => string $uniqueName).
246 public static function &fieldKeys() {
247 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
248 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
250 return Civi
::$statics[__CLASS__
]['fieldKeys'];
254 * Returns the names of this table
258 public static function getTableName() {
259 return self
::$_tableName;
263 * Returns if this table needs to be logged
267 public function getLog() {
272 * Returns the list of fields that can be imported
274 * @param bool $prefix
278 public static function &import($prefix = FALSE) {
279 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'file', $prefix, []);
284 * Returns the list of fields that can be exported
286 * @param bool $prefix
290 public static function &export($prefix = FALSE) {
291 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'file', $prefix, []);
296 * Returns the list of indices
298 * @param bool $localize
302 public static function indices($localize = TRUE) {
304 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;