‪TYPO3CMS  11.5
PDOStatement.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\DBAL\Driver\PDO\Exception as PDOException;
21 use Doctrine\DBAL\Driver\PDO\Statement as DoctrineDbalPDOStatement;
22 use PDO;
23 
24 class ‪PDOStatement extends DoctrineDbalPDOStatement
25 {
30  use PDOStatementImplementation;
31 
38  protected function ‪mapResourceToString($record)
39  {
40  if (is_array($record)) {
41  foreach ($record as $k => $value) {
42  if (is_resource($value)) {
43  $record[$k] = stream_get_contents($value);
44  }
45  }
46  }
47 
48  return $record;
49  }
50 
54  public function ‪fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
55  {
56  try {
57  $record = parent::fetch($fetchMode, $cursorOrientation, $cursorOffset);
58  $record = $this->‪mapResourceToString($record);
59  return $record;
60  } catch (\PDOException $exception) {
61  throw new PDOException($exception);
62  }
63  }
64 
68  public function ‪fetchOne($columnIndex = 0)
69  {
70  try {
71  $record = parent::fetchColumn($columnIndex);
72  $record = $this->‪mapResourceToString($record);
73  return $record;
74  } catch (\PDOException $exception) {
75  throw new PDOException($exception);
76  }
77  }
78 
82  public function ‪fetchColumn($columnIndex = 0)
83  {
84  return $this->‪fetchOne($columnIndex);
85  }
86 }
‪TYPO3\CMS\Core\Database\Driver\PDOStatement\fetch
‪fetch($fetchMode=null, $cursorOrientation=PDO::FETCH_ORI_NEXT, $cursorOffset=0)
Definition: PDOStatement.php:54
‪TYPO3\CMS\Core\Database\Driver\PDOStatement\mapResourceToString
‪mixed mapResourceToString($record)
Definition: PDOStatement.php:38
‪TYPO3\CMS\Core\Database\Driver\PDOStatement
Definition: PDOStatement.php:25
‪TYPO3\CMS\Core\Database\Driver\PDOStatement\fetchColumn
‪fetchColumn($columnIndex=0)
Definition: PDOStatement.php:82
‪TYPO3\CMS\Core\Database\Driver\PDOStatement\fetchOne
‪fetchOne($columnIndex=0)
Definition: PDOStatement.php:68
‪TYPO3\CMS\Core\Database\Driver
Definition: PDOConnection.php:18