[BUGFIX] Fix usage of preparedStatement object in $query->statement
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Qom / Statement.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic\Qom;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2013 Extbase Team (http://forge.typo3.org/projects/typo3v4-mvc)
8 * Extbase is a backport of TYPO3 Flow. All credits go to the TYPO3 Flow team.
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the text file GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 /**
31 * A statement acting as a constraint.
32 */
33 class Statement {
34
35 /**
36 * @var string|\TYPO3\CMS\Core\Database\PreparedStatement
37 */
38 protected $statement;
39
40 /**
41 * @var array
42 */
43 protected $boundVariables = array();
44
45 /**
46 * Constructs the Statement instance
47 *
48 * @param string|\TYPO3\CMS\Core\Database\PreparedStatement $statement The statement as sql string or TYPO3\CMS\Core\Database\PreparedStatement
49 * @param array $boundVariables An array of variables to bind to the statement, only to be used with preparedStatement
50 */
51 public function __construct($statement, array $boundVariables = array()) {
52 // @deprecated since 6.2, using $boundVariables without preparedStatement will be removed in two versions
53 if (
54 !empty($boundVariables)
55 && !($statement instanceof \TYPO3\CMS\Core\Database\PreparedStatement)
56 ) {
57 \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Using boundVariables'
58 . ' in Extbase\'s custom statement without using preparedStatement is'
59 . ' deprecated since TYPO3 6.2 and will be removed in two versions.');
60 }
61 $this->statement = $statement;
62 $this->boundVariables = $boundVariables;
63 }
64
65 /**
66 * Gets the statement.
67 *
68 * @return string|\TYPO3\CMS\Core\Database\PreparedStatement the statement; non-null
69 */
70 public function getStatement() {
71 return $this->statement;
72 }
73
74 /**
75 * Gets the bound variables
76 *
77 * @return array $boundVariables
78 */
79 public function getBoundVariables() {
80 return $this->boundVariables;
81 }
82 }