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:6bf3c3f06e1c01d91a6c6cf5ada7a889)
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',
148 'name' => 'file_type_id',
149 'type' => CRM_Utils_Type
::T_INT
,
150 'title' => ts('File Type'),
151 'description' => ts('Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.'),
152 'where' => 'civicrm_file.file_type_id',
153 'table_name' => 'civicrm_file',
155 'bao' => 'CRM_Core_BAO_File',
160 'name' => 'mime_type',
161 'type' => CRM_Utils_Type
::T_STRING
,
162 'title' => ts('Mime Type'),
163 'description' => ts('mime type of the document'),
165 'size' => CRM_Utils_Type
::HUGE
,
166 'where' => 'civicrm_file.mime_type',
167 'table_name' => 'civicrm_file',
169 'bao' => 'CRM_Core_BAO_File',
175 'type' => CRM_Utils_Type
::T_STRING
,
176 'title' => ts('Path'),
177 'description' => ts('uri of the file on disk'),
179 'size' => CRM_Utils_Type
::HUGE
,
180 'where' => 'civicrm_file.uri',
181 'table_name' => 'civicrm_file',
183 'bao' => 'CRM_Core_BAO_File',
188 'name' => 'document',
189 'type' => CRM_Utils_Type
::T_MEDIUMBLOB
,
190 'title' => ts('File Contents'),
191 'description' => ts('contents of the document'),
192 'where' => 'civicrm_file.document',
193 'table_name' => 'civicrm_file',
195 'bao' => 'CRM_Core_BAO_File',
200 'name' => 'description',
201 'type' => CRM_Utils_Type
::T_STRING
,
202 'title' => ts('File Description'),
203 'description' => ts('Additional descriptive text regarding this attachment (optional).'),
205 'size' => CRM_Utils_Type
::HUGE
,
206 'where' => 'civicrm_file.description',
207 'table_name' => 'civicrm_file',
209 'bao' => 'CRM_Core_BAO_File',
214 'name' => 'upload_date',
215 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
216 'title' => ts('File Upload Date'),
217 'description' => ts('Date and time that this attachment was uploaded or written to server.'),
218 'where' => 'civicrm_file.upload_date',
219 'table_name' => 'civicrm_file',
221 'bao' => 'CRM_Core_BAO_File',
226 'name' => 'created_id',
227 'type' => CRM_Utils_Type
::T_INT
,
228 'title' => ts('Created By Contact ID'),
229 'description' => ts('FK to civicrm_contact, who uploaded this file'),
230 'where' => 'civicrm_file.created_id',
231 'table_name' => 'civicrm_file',
233 'bao' => 'CRM_Core_BAO_File',
235 'FKClassName' => 'CRM_Contact_DAO_Contact',
237 'label' => ts("Created By"),
242 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
244 return Civi
::$statics[__CLASS__
]['fields'];
248 * Return a mapping from field-name to the corresponding key (as used in fields()).
251 * Array(string $name => string $uniqueName).
253 public static function &fieldKeys() {
254 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
255 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
257 return Civi
::$statics[__CLASS__
]['fieldKeys'];
261 * Returns the names of this table
265 public static function getTableName() {
266 return self
::$_tableName;
270 * Returns if this table needs to be logged
274 public function getLog() {
279 * Returns the list of fields that can be imported
281 * @param bool $prefix
285 public static function &import($prefix = FALSE) {
286 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'file', $prefix, []);
291 * Returns the list of fields that can be exported
293 * @param bool $prefix
297 public static function &export($prefix = FALSE) {
298 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'file', $prefix, []);
303 * Returns the list of indices
305 * @param bool $localize
309 public static function indices($localize = TRUE) {
311 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;