| 1 |
lars |
1 |
<?php
|
|
|
2 |
/*
|
|
|
3 |
* $Id: Interface.php 7490 2010-03-29 19:53:27Z jwage $
|
|
|
4 |
*
|
|
|
5 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
6 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
7 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
8 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
9 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
10 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
11 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
12 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
13 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
14 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
15 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
16 |
*
|
|
|
17 |
* This software consists of voluntary contributions made by many individuals
|
|
|
18 |
* and is licensed under the LGPL. For more information, see
|
|
|
19 |
* <http://www.doctrine-project.org>.
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Interface for Doctrine adapter statements
|
|
|
24 |
*
|
|
|
25 |
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
|
|
26 |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
|
|
27 |
* @package Doctrine
|
|
|
28 |
* @subpackage Adapter
|
|
|
29 |
* @link www.doctrine-project.org
|
|
|
30 |
* @since 1.0
|
|
|
31 |
* @version $Revision: 7490 $
|
|
|
32 |
*/
|
|
|
33 |
interface Doctrine_Adapter_Statement_Interface
|
|
|
34 |
{
|
|
|
35 |
/**
|
|
|
36 |
* Bind a column to a PHP variable
|
|
|
37 |
*
|
|
|
38 |
* @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
|
|
|
39 |
* If using the column name, be aware that the name should match
|
|
|
40 |
* the case of the column, as returned by the driver.
|
|
|
41 |
* @param string $param Name of the PHP variable to which the column will be bound.
|
|
|
42 |
* @param integer $type Data type of the parameter, specified by the Doctrine_Core::PARAM_* constants.
|
|
|
43 |
* @return boolean Returns TRUE on success or FALSE on failure
|
|
|
44 |
*/
|
|
|
45 |
public function bindColumn($column, $param, $type = null);
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
* Binds a value to a corresponding named or question mark
|
|
|
49 |
* placeholder in the SQL statement that was use to prepare the statement.
|
|
|
50 |
*
|
|
|
51 |
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
|
|
|
52 |
* this will be a parameter name of the form :name. For a prepared statement
|
|
|
53 |
* using question mark placeholders, this will be the 1-indexed position of the parameter
|
|
|
54 |
*
|
|
|
55 |
* @param mixed $value The value to bind to the parameter.
|
|
|
56 |
* @param integer $type Explicit data type for the parameter using the Doctrine_Core::PARAM_* constants.
|
|
|
57 |
*
|
|
|
58 |
* @return boolean Returns TRUE on success or FALSE on failure.
|
|
|
59 |
*/
|
|
|
60 |
public function bindValue($param, $value, $type = null);
|
|
|
61 |
|
|
|
62 |
/**
|
|
|
63 |
* Binds a PHP variable to a corresponding named or question mark placeholder in the
|
|
|
64 |
* SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(),
|
|
|
65 |
* the variable is bound as a reference and will only be evaluated at the time
|
|
|
66 |
* that Doctrine_Adapter_Statement_Interface->execute() is called.
|
|
|
67 |
*
|
|
|
68 |
* Most parameters are input parameters, that is, parameters that are
|
|
|
69 |
* used in a read-only fashion to build up the query. Some drivers support the invocation
|
|
|
70 |
* of stored procedures that return data as output parameters, and some also as input/output
|
|
|
71 |
* parameters that both send in data and are updated to receive it.
|
|
|
72 |
*
|
|
|
73 |
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
|
|
|
74 |
* this will be a parameter name of the form :name. For a prepared statement
|
|
|
75 |
* using question mark placeholders, this will be the 1-indexed position of the parameter
|
|
|
76 |
*
|
|
|
77 |
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
|
|
|
78 |
*
|
|
|
79 |
* @param integer $type Explicit data type for the parameter using the Doctrine_Core::PARAM_* constants. To return
|
|
|
80 |
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
|
|
|
81 |
* Doctrine_Core::PARAM_INPUT_OUTPUT bits for the data_type parameter.
|
|
|
82 |
*
|
|
|
83 |
* @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter
|
|
|
84 |
* from a stored procedure, you must explicitly set the length.
|
|
|
85 |
* @param mixed $driverOptions
|
|
|
86 |
* @return boolean Returns TRUE on success or FALSE on failure.
|
|
|
87 |
*/
|
|
|
88 |
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array());
|
|
|
89 |
|
|
|
90 |
/**
|
|
|
91 |
* Closes the cursor, enabling the statement to be executed again.
|
|
|
92 |
*
|
|
|
93 |
* @return boolean Returns TRUE on success or FALSE on failure.
|
|
|
94 |
*/
|
|
|
95 |
public function closeCursor();
|
|
|
96 |
|
|
|
97 |
/**
|
|
|
98 |
* Returns the number of columns in the result set
|
|
|
99 |
*
|
|
|
100 |
* @return integer Returns the number of columns in the result set represented
|
|
|
101 |
* by the Doctrine_Adapter_Statement_Interface object. If there is no result set,
|
|
|
102 |
* this method should return 0.
|
|
|
103 |
*/
|
|
|
104 |
public function columnCount();
|
|
|
105 |
|
|
|
106 |
/**
|
|
|
107 |
* Fetch the SQLSTATE associated with the last operation on the statement handle
|
|
|
108 |
*
|
|
|
109 |
* @see Doctrine_Adapter_Interface::errorCode()
|
|
|
110 |
* @return string error code string
|
|
|
111 |
*/
|
|
|
112 |
public function errorCode();
|
|
|
113 |
|
|
|
114 |
/**
|
|
|
115 |
* Fetch extended error information associated with the last operation on the statement handle
|
|
|
116 |
*
|
|
|
117 |
* @see Doctrine_Adapter_Interface::errorInfo()
|
|
|
118 |
* @return array error info array
|
|
|
119 |
*/
|
|
|
120 |
public function errorInfo();
|
|
|
121 |
|
|
|
122 |
/**
|
|
|
123 |
* Executes a prepared statement
|
|
|
124 |
*
|
|
|
125 |
* If the prepared statement included parameter markers, you must either:
|
|
|
126 |
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
|
|
|
127 |
* bound variables pass their value as input and receive the output value,
|
|
|
128 |
* if any, of their associated parameter markers or pass an array of input-only
|
|
|
129 |
* parameter values
|
|
|
130 |
*
|
|
|
131 |
*
|
|
|
132 |
* @param array $params An array of values with as many elements as there are
|
|
|
133 |
* bound parameters in the SQL statement being executed.
|
|
|
134 |
* @return boolean Returns TRUE on success or FALSE on failure.
|
|
|
135 |
*/
|
|
|
136 |
public function execute($params = null);
|
|
|
137 |
|
|
|
138 |
/**
|
|
|
139 |
* fetch
|
|
|
140 |
*
|
|
|
141 |
* @see Doctrine_Core::FETCH_* constants
|
|
|
142 |
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
|
|
|
143 |
* This value must be one of the Doctrine_Core::FETCH_* constants,
|
|
|
144 |
* defaulting to Doctrine_Core::FETCH_BOTH
|
|
|
145 |
*
|
|
|
146 |
* @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
|
|
|
147 |
* this value determines which row will be returned to the caller.
|
|
|
148 |
* This value must be one of the Doctrine_Core::FETCH_ORI_* constants, defaulting to
|
|
|
149 |
* Doctrine_Core::FETCH_ORI_NEXT. To request a scrollable cursor for your
|
|
|
150 |
* Doctrine_Adapter_Statement_Interface object,
|
|
|
151 |
* you must set the Doctrine_Core::ATTR_CURSOR attribute to Doctrine_Core::CURSOR_SCROLL when you
|
|
|
152 |
* prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
|
|
|
153 |
*
|
|
|
154 |
* @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the
|
|
|
155 |
* $cursorOrientation parameter is set to Doctrine_Core::FETCH_ORI_ABS, this value specifies
|
|
|
156 |
* the absolute number of the row in the result set that shall be fetched.
|
|
|
157 |
*
|
|
|
158 |
* For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for
|
|
|
159 |
* which the $cursorOrientation parameter is set to Doctrine_Core::FETCH_ORI_REL, this value
|
|
|
160 |
* specifies the row to fetch relative to the cursor position before
|
|
|
161 |
* Doctrine_Adapter_Statement_Interface->fetch() was called.
|
|
|
162 |
*
|
|
|
163 |
* @return mixed
|
|
|
164 |
*/
|
|
|
165 |
public function fetch($fetchStyle = Doctrine_Core::FETCH_BOTH,
|
|
|
166 |
$cursorOrientation = Doctrine_Core::FETCH_ORI_NEXT,
|
|
|
167 |
$cursorOffset = null);
|
|
|
168 |
|
|
|
169 |
/**
|
|
|
170 |
* Returns an array containing all of the result set rows
|
|
|
171 |
*
|
|
|
172 |
* @param integer $fetchStyle Controls how the next row will be returned to the caller.
|
|
|
173 |
* This value must be one of the Doctrine_Core::FETCH_* constants,
|
|
|
174 |
* defaulting to Doctrine_Core::FETCH_BOTH
|
|
|
175 |
*
|
|
|
176 |
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
|
|
|
177 |
* Doctrine_Core::FETCH_COLUMN. Defaults to 0.
|
|
|
178 |
*
|
|
|
179 |
* @return array
|
|
|
180 |
*/
|
|
|
181 |
public function fetchAll($fetchStyle = Doctrine_Core::FETCH_BOTH);
|
|
|
182 |
|
|
|
183 |
/**
|
|
|
184 |
* Returns a single column from the next row of a
|
|
|
185 |
* result set or FALSE if there are no more rows.
|
|
|
186 |
*
|
|
|
187 |
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
|
|
|
188 |
* value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn()
|
|
|
189 |
* fetches the first column.
|
|
|
190 |
*
|
|
|
191 |
* @return string returns a single column in the next row of a result set.
|
|
|
192 |
*/
|
|
|
193 |
public function fetchColumn($columnIndex = 0);
|
|
|
194 |
|
|
|
195 |
/**
|
|
|
196 |
* Fetches the next row and returns it as an object.
|
|
|
197 |
*
|
|
|
198 |
* Fetches the next row and returns it as an object. This function is an alternative to
|
|
|
199 |
* Doctrine_Adapter_Statement_Interface->fetch() with Doctrine_Core::FETCH_CLASS or Doctrine_Core::FETCH_OBJ style.
|
|
|
200 |
*
|
|
|
201 |
* @param string $className Name of the created class, defaults to stdClass.
|
|
|
202 |
* @param array $args Elements of this array are passed to the constructor.
|
|
|
203 |
*
|
|
|
204 |
* @return mixed an instance of the required class with property names that correspond
|
|
|
205 |
* to the column names or FALSE in case of an error.
|
|
|
206 |
*/
|
|
|
207 |
public function fetchObject($className = 'stdClass', $args = array());
|
|
|
208 |
|
|
|
209 |
/**
|
|
|
210 |
* Retrieve a statement attribute
|
|
|
211 |
*
|
|
|
212 |
* @param integer $attribute
|
|
|
213 |
* @see Doctrine_Core::ATTR_* constants
|
|
|
214 |
* @return mixed the attribute value
|
|
|
215 |
*/
|
|
|
216 |
public function getAttribute($attribute);
|
|
|
217 |
|
|
|
218 |
/**
|
|
|
219 |
* Returns metadata for a column in a result set
|
|
|
220 |
*
|
|
|
221 |
* @param integer $column The 0-indexed column in the result set.
|
|
|
222 |
*
|
|
|
223 |
* @return array Associative meta data array with the following structure:
|
|
|
224 |
*
|
|
|
225 |
* native_type The PHP native type used to represent the column value.
|
|
|
226 |
* driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
|
|
|
227 |
* flags Any flags set for this column.
|
|
|
228 |
* name The name of this column as returned by the database.
|
|
|
229 |
* len The length of this column. Normally -1 for types other than floating point decimals.
|
|
|
230 |
* precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
|
|
|
231 |
* pdo_type The type of this column as represented by the PDO::PARAM_* constants.
|
|
|
232 |
*/
|
|
|
233 |
public function getColumnMeta($column);
|
|
|
234 |
|
|
|
235 |
/**
|
|
|
236 |
* Advances to the next rowset in a multi-rowset statement handle
|
|
|
237 |
*
|
|
|
238 |
* Some database servers support stored procedures that return more than one rowset
|
|
|
239 |
* (also known as a result set). The nextRowset() method enables you to access the second
|
|
|
240 |
* and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
|
|
|
241 |
* different set of columns from the preceding rowset.
|
|
|
242 |
*
|
|
|
243 |
* @return boolean Returns TRUE on success or FALSE on failure.
|
|
|
244 |
*/
|
|
|
245 |
public function nextRowset();
|
|
|
246 |
|
|
|
247 |
/**
|
|
|
248 |
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
|
|
|
249 |
* executed by the corresponding object.
|
|
|
250 |
*
|
|
|
251 |
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
|
|
|
252 |
* some databases may return the number of rows returned by that statement. However,
|
|
|
253 |
* this behaviour is not guaranteed for all databases and should not be
|
|
|
254 |
* relied on for portable applications.
|
|
|
255 |
*
|
|
|
256 |
* @return integer Returns the number of rows.
|
|
|
257 |
*/
|
|
|
258 |
public function rowCount();
|
|
|
259 |
|
|
|
260 |
/**
|
|
|
261 |
* Set a statement attribute
|
|
|
262 |
*
|
|
|
263 |
* @param integer $attribute
|
|
|
264 |
* @param mixed $value the value of given attribute
|
|
|
265 |
* @return boolean Returns TRUE on success or FALSE on failure.
|
|
|
266 |
*/
|
|
|
267 |
public function setAttribute($attribute, $value);
|
|
|
268 |
|
|
|
269 |
/**
|
|
|
270 |
* Set the default fetch mode for this statement
|
|
|
271 |
*
|
|
|
272 |
* @param integer $mode The fetch mode must be one of the Doctrine_Core::FETCH_* constants.
|
|
|
273 |
* @return boolean Returns 1 on success or FALSE on failure.
|
|
|
274 |
*/
|
|
|
275 |
public function setFetchMode($mode, $arg1 = null, $arg2 = null);
|
|
|
276 |
}
|