‪TYPO3CMS  10.4
DatabaseRecord.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
25 {
29  protected ‪$table;
30 
34  protected ‪$uid;
35 
39  protected ‪$row;
40 
48  public static function ‪create(‪$table, ‪$uid)
49  {
50  return GeneralUtility::makeInstance(DatabaseRecord::class, ‪$table, ‪$uid);
51  }
52 
60  public static function ‪createFromArray(‪$table, array ‪$row)
61  {
62  return GeneralUtility::makeInstance(DatabaseRecord::class, ‪$table, ‪$row['uid'], ‪$row);
63  }
64 
70  public function ‪__construct(‪$table, ‪$uid, array ‪$row = null)
71  {
72  $this->‪setTable(‪$table);
73  $this->‪setUid(‪$uid);
74  if ($row !== null) {
75  $this->‪setRow($row);
76  }
77  }
78 
84  public function ‪getTable()
85  {
86  return ‪$this->table;
87  }
88 
94  public function ‪setTable(‪$table)
95  {
96  $this->table = ‪$table;
97  }
98 
104  public function ‪getUid()
105  {
106  return ‪$this->uid;
107  }
108 
114  public function ‪setUid(‪$uid)
115  {
116  $this->uid = (int)‪$uid;
117  }
118 
124  public function ‪getRow()
125  {
126  $this->‪loadRow();
127  return ‪$this->row;
128  }
129 
135  public function ‪setRow(array ‪$row)
136  {
137  $this->row = ‪$row;
138  }
139 
145  public function ‪getIdentifier()
146  {
147  return implode(':', [$this->‪getTable(), $this->‪getUid()]);
148  }
149 
153  protected function ‪loadRow()
154  {
155  if ($this->row === null) {
156  $this->row = ‪BackendUtility::getRecord($this->‪getTable(), $this->‪getUid());
157  }
158  }
159 }
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\setUid
‪setUid($uid)
Definition: DatabaseRecord.php:111
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\getIdentifier
‪string getIdentifier()
Definition: DatabaseRecord.php:142
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\createFromArray
‪static DatabaseRecord createFromArray($table, array $row)
Definition: DatabaseRecord.php:57
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\$table
‪string $table
Definition: DatabaseRecord.php:28
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\getTable
‪string getTable()
Definition: DatabaseRecord.php:81
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\$row
‪array $row
Definition: DatabaseRecord.php:36
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
Definition: DatabaseRecord.php:25
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\loadRow
‪loadRow()
Definition: DatabaseRecord.php:150
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\setTable
‪setTable($table)
Definition: DatabaseRecord.php:91
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\__construct
‪__construct($table, $uid, array $row=null)
Definition: DatabaseRecord.php:67
‪TYPO3\CMS\Workspaces\Domain\Model
Definition: CombinedRecord.php:16
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\getUid
‪int getUid()
Definition: DatabaseRecord.php:101
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:95
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\getRow
‪array getRow()
Definition: DatabaseRecord.php:121
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\create
‪static DatabaseRecord create($table, $uid)
Definition: DatabaseRecord.php:45
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\$uid
‪int $uid
Definition: DatabaseRecord.php:32
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\setRow
‪setRow(array $row)
Definition: DatabaseRecord.php:132