Delete entities in the reverse order that they were created
[civicrm-core.git] / CRM / Core / DAO / File.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Core/File.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
022785d8 9 * (GenCodeChecksum:996b2702471b24fb13c740ef104ea1f9)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the File entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_File extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_file';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
c3fc2621
CW
29 static $_log = TRUE;
30
e501603b
TO
31 /**
32 * Unique ID
33 *
34 * @var int unsigned
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.
40 *
41 * @var int unsigned
42 */
43 public $file_type_id;
c3fc2621 44
e501603b
TO
45 /**
46 * mime type of the document
47 *
48 * @var string
49 */
50 public $mime_type;
c3fc2621 51
e501603b
TO
52 /**
53 * uri of the file on disk
54 *
55 * @var string
56 */
57 public $uri;
c3fc2621 58
e501603b
TO
59 /**
60 * contents of the document
61 *
62 * @var mediumblob
63 */
64 public $document;
c3fc2621 65
e501603b
TO
66 /**
67 * Additional descriptive text regarding this attachment (optional).
68 *
69 * @var string
70 */
71 public $description;
c3fc2621 72
e501603b
TO
73 /**
74 * Date and time that this attachment was uploaded or written to server.
75 *
76 * @var datetime
77 */
78 public $upload_date;
c3fc2621 79
e501603b 80 /**
f41f0342 81 * Class constructor.
e501603b 82 */
c3fc2621 83 public function __construct() {
e501603b
TO
84 $this->__table = 'civicrm_file';
85 parent::__construct();
86 }
c3fc2621 87
e501603b
TO
88 /**
89 * Returns all the column names of this table
90 *
91 * @return array
92 */
c3fc2621 93 public static function &fields() {
346aaaba 94 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
95 Civi::$statics[__CLASS__]['fields'] = [
96 'id' => [
e501603b
TO
97 'name' => 'id',
98 'type' => CRM_Utils_Type::T_INT,
c3fc2621 99 'title' => ts('File ID'),
e501603b 100 'description' => 'Unique ID',
c3fc2621 101 'required' => TRUE,
522a26c9 102 'table_name' => 'civicrm_file',
103 'entity' => 'File',
104 'bao' => 'CRM_Core_BAO_File',
6a7e5e5d 105 'localizable' => 0,
c3fc2621
CW
106 ],
107 'file_type_id' => [
e501603b
TO
108 'name' => 'file_type_id',
109 'type' => CRM_Utils_Type::T_INT,
c3fc2621 110 'title' => ts('File Type'),
e501603b 111 'description' => 'Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.',
522a26c9 112 'table_name' => 'civicrm_file',
113 'entity' => 'File',
114 'bao' => 'CRM_Core_BAO_File',
6a7e5e5d 115 'localizable' => 0,
c3fc2621
CW
116 ],
117 'mime_type' => [
e501603b
TO
118 'name' => 'mime_type',
119 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 120 'title' => ts('Mime Type'),
e501603b
TO
121 'description' => 'mime type of the document',
122 'maxlength' => 255,
123 'size' => CRM_Utils_Type::HUGE,
522a26c9 124 'table_name' => 'civicrm_file',
125 'entity' => 'File',
126 'bao' => 'CRM_Core_BAO_File',
6a7e5e5d 127 'localizable' => 0,
c3fc2621
CW
128 ],
129 'uri' => [
e501603b
TO
130 'name' => 'uri',
131 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 132 'title' => ts('Path'),
e501603b
TO
133 'description' => 'uri of the file on disk',
134 'maxlength' => 255,
135 'size' => CRM_Utils_Type::HUGE,
522a26c9 136 'table_name' => 'civicrm_file',
137 'entity' => 'File',
138 'bao' => 'CRM_Core_BAO_File',
6a7e5e5d 139 'localizable' => 0,
c3fc2621
CW
140 ],
141 'document' => [
e501603b
TO
142 'name' => 'document',
143 'type' => CRM_Utils_Type::T_MEDIUMBLOB,
c3fc2621 144 'title' => ts('File Contents'),
e501603b 145 'description' => 'contents of the document',
522a26c9 146 'table_name' => 'civicrm_file',
147 'entity' => 'File',
148 'bao' => 'CRM_Core_BAO_File',
6a7e5e5d 149 'localizable' => 0,
c3fc2621
CW
150 ],
151 'description' => [
e501603b
TO
152 'name' => 'description',
153 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 154 'title' => ts('File Description'),
e501603b
TO
155 'description' => 'Additional descriptive text regarding this attachment (optional).',
156 'maxlength' => 255,
157 'size' => CRM_Utils_Type::HUGE,
522a26c9 158 'table_name' => 'civicrm_file',
159 'entity' => 'File',
160 'bao' => 'CRM_Core_BAO_File',
6a7e5e5d 161 'localizable' => 0,
c3fc2621
CW
162 ],
163 'upload_date' => [
e501603b
TO
164 'name' => 'upload_date',
165 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 166 'title' => ts('File Upload Date'),
e501603b 167 'description' => 'Date and time that this attachment was uploaded or written to server.',
522a26c9 168 'table_name' => 'civicrm_file',
169 'entity' => 'File',
170 'bao' => 'CRM_Core_BAO_File',
6a7e5e5d 171 'localizable' => 0,
c3fc2621
CW
172 ],
173 ];
346aaaba 174 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 175 }
346aaaba 176 return Civi::$statics[__CLASS__]['fields'];
e501603b 177 }
c3fc2621 178
e501603b 179 /**
bd8e0b14 180 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
181 *
182 * @return array
bd8e0b14 183 * Array(string $name => string $uniqueName).
e501603b 184 */
c3fc2621 185 public static function &fieldKeys() {
bd8e0b14
TO
186 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
187 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 188 }
bd8e0b14 189 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 190 }
c3fc2621 191
e501603b
TO
192 /**
193 * Returns the names of this table
194 *
195 * @return string
196 */
c3fc2621 197 public static function getTableName() {
e501603b
TO
198 return self::$_tableName;
199 }
c3fc2621 200
e501603b
TO
201 /**
202 * Returns if this table needs to be logged
203 *
c3fc2621 204 * @return bool
e501603b 205 */
c3fc2621 206 public function getLog() {
e501603b
TO
207 return self::$_log;
208 }
c3fc2621 209
e501603b
TO
210 /**
211 * Returns the list of fields that can be imported
212 *
213 * @param bool $prefix
214 *
215 * @return array
216 */
c3fc2621
CW
217 public static function &import($prefix = FALSE) {
218 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'file', $prefix, []);
60808919 219 return $r;
e501603b 220 }
c3fc2621 221
e501603b
TO
222 /**
223 * Returns the list of fields that can be exported
224 *
225 * @param bool $prefix
226 *
227 * @return array
228 */
c3fc2621
CW
229 public static function &export($prefix = FALSE) {
230 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'file', $prefix, []);
60808919 231 return $r;
e501603b 232 }
c3fc2621 233
e7a6b91a
AS
234 /**
235 * Returns the list of indices
c3fc2621
CW
236 *
237 * @param bool $localize
238 *
239 * @return array
e7a6b91a
AS
240 */
241 public static function indices($localize = TRUE) {
c3fc2621 242 $indices = [];
e7a6b91a
AS
243 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
244 }
c3fc2621 245
e501603b 246}