‪TYPO3CMS  9.5
DatabaseRecord.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
24 {
28  protected ‪$table;
29 
33  protected ‪$uid;
34 
38  protected ‪$row;
39 
47  public static function ‪create(‪$table, ‪$uid)
48  {
49  return GeneralUtility::makeInstance(DatabaseRecord::class, ‪$table, ‪$uid);
50  }
51 
59  public static function ‪createFromArray(‪$table, array ‪$row)
60  {
61  return GeneralUtility::makeInstance(DatabaseRecord::class, ‪$table, ‪$row['uid'], ‪$row);
62  }
63 
69  public function ‪__construct(‪$table, ‪$uid, array ‪$row = null)
70  {
71  $this->‪setTable(‪$table);
72  $this->‪setUid(‪$uid);
73  if ($row !== null) {
74  $this->‪setRow($row);
75  }
76  }
77 
83  public function ‪getTable()
84  {
85  return ‪$this->table;
86  }
87 
93  public function ‪setTable(‪$table)
94  {
95  $this->table = ‪$table;
96  }
97 
103  public function ‪getUid()
104  {
105  return ‪$this->uid;
106  }
107 
113  public function ‪setUid(‪$uid)
114  {
115  $this->uid = (int)‪$uid;
116  }
117 
123  public function ‪getRow()
124  {
125  $this->‪loadRow();
126  return ‪$this->row;
127  }
128 
134  public function ‪setRow(array ‪$row)
135  {
136  $this->row = ‪$row;
137  }
138 
144  public function ‪getIdentifier()
145  {
146  return implode(':', [$this->‪getTable(), $this->‪getUid()]);
147  }
148 
152  protected function ‪loadRow()
153  {
154  if ($this->row === null) {
155  $this->row = ‪BackendUtility::getRecord($this->‪getTable(), $this->‪getUid());
156  }
157  }
158 }
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\setUid
‪setUid($uid)
Definition: DatabaseRecord.php:110
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\getIdentifier
‪string getIdentifier()
Definition: DatabaseRecord.php:141
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\createFromArray
‪static DatabaseRecord createFromArray($table, array $row)
Definition: DatabaseRecord.php:56
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\$table
‪string $table
Definition: DatabaseRecord.php:27
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\getTable
‪string getTable()
Definition: DatabaseRecord.php:80
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\$row
‪array $row
Definition: DatabaseRecord.php:35
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
Definition: DatabaseRecord.php:24
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\loadRow
‪loadRow()
Definition: DatabaseRecord.php:149
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\setTable
‪setTable($table)
Definition: DatabaseRecord.php:90
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\__construct
‪__construct($table, $uid, array $row=null)
Definition: DatabaseRecord.php:66
‪TYPO3\CMS\Workspaces\Domain\Model
Definition: CombinedRecord.php:2
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\getUid
‪int getUid()
Definition: DatabaseRecord.php:100
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:130
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\getRow
‪array getRow()
Definition: DatabaseRecord.php:120
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\create
‪static DatabaseRecord create($table, $uid)
Definition: DatabaseRecord.php:44
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\$uid
‪int $uid
Definition: DatabaseRecord.php:31
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\setRow
‪setRow(array $row)
Definition: DatabaseRecord.php:131