# Source for file Interface.php

Documentation is available at Interface.php

1. <?php
2. /*
3. * $Id: Interface.php 1080 2007-02-10 18:17:08Z romanb $
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.phpdoctrine.com>.
20. */
21. /**
22. * Doctrine_Adapter_Statement
23. *
24. * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
25. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
26. * @package Doctrine
27. * @category Object Relational Mapping
28. * @link www.phpdoctrine.com
29. * @since 1.0
30. * @version $Revision: 1080 $
31. */
32. interface Doctrine_Adapter_Statement_Interface
33. {
34. /**
35. * bindColumn
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::PARAM_* constants.
43. * @return boolean Returns TRUE on success or FALSE on failure
44. */
45. public function bindColumn($column, $param, $type = null);
46. /**
47. * bindValue
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::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. * bindParam
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::PARAM_* constants. To return
80. * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
81. * Doctrine::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. * closeCursor
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. * columnCount
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. * errorCode
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. * errorInfo
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. * execute
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. * fetch
139. *
140. * @see Doctrine::FETCH_* constants
141. * @param integer $fetchStyle Controls how the next row will be returned to the caller.
142. * This value must be one of the Doctrine::FETCH_* constants,
143. * defaulting to Doctrine::FETCH_BOTH
144. *
145. * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
146. * this value determines which row will be returned to the caller.
147. * This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to
148. * Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your
149. * Doctrine_Adapter_Statement_Interface object,
150. * you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
151. * prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
152. *
153. * @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the
154. * $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies
155. * the absolute number of the row in the result set that shall be fetched.
156. *
157. * For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for
158. * which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value
159. * specifies the row to fetch relative to the cursor position before
160. * Doctrine_Adapter_Statement_Interface->fetch() was called.
161. *
162. * @return mixed
163. */
164. public function fetch($fetchStyle = Doctrine::FETCH_BOTH,
165. $cursorOrientation = Doctrine::FETCH_ORI_NEXT,
166. $cursorOffset = null);
167. /**
168. * fetchAll
169. * Returns an array containing all of the result set rows
170. *
171. * @param integer $fetchStyle Controls how the next row will be returned to the caller.
172. * This value must be one of the Doctrine::FETCH_* constants,
173. * defaulting to Doctrine::FETCH_BOTH
174. *
175. * @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
176. * Doctrine::FETCH_COLUMN. Defaults to 0.
177. *
178. * @return array
179. */
180. public function fetchAll($fetchStyle = Doctrine::FETCH_BOTH);
181. /**
182. * fetchColumn
183. * Returns a single column from the next row of a
184. * result set or FALSE if there are no more rows.
185. *
186. * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
187. * value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn()
188. * fetches the first column.
189. *
190. * @return string returns a single column in the next row of a result set.
191. */
192. public function fetchColumn($columnIndex = 0);
193. /**
194. * fetchObject
195. * Fetches the next row and returns it as an object.
196. *
197. * Fetches the next row and returns it as an object. This function is an alternative to
198. * Doctrine_Adapter_Statement_Interface->fetch() with Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style.
199. *
200. * @param string $className Name of the created class, defaults to stdClass.
201. * @param array $args Elements of this array are passed to the constructor.
202. *
203. * @return mixed an instance of the required class with property names that correspond
204. * to the column names or FALSE in case of an error.
205. */
206. public function fetchObject($className = 'stdClass', $args = array());
207. /**
208. * getAttribute
209. * Retrieve a statement attribute
210. *
211. * @param integer $attribute
212. * @see Doctrine::ATTR_* constants
213. * @return mixed the attribute value
214. */
215. public function getAttribute($attribute);
216. /**
217. * getColumnMeta
218. * Returns metadata for a column in a result set
219. *
220. * @param integer $column The 0-indexed column in the result set.
221. *
222. * @return array Associative meta data array with the following structure:
223. *
224. * native_type The PHP native type used to represent the column value.
225. * 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().
226. * flags Any flags set for this column.
227. * name The name of this column as returned by the database.
228. * len The length of this column. Normally -1 for types other than floating point decimals.
229. * precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
230. * pdo_type The type of this column as represented by the PDO::PARAM_* constants.
231. */
232. public function getColumnMeta($column);
233. /**
234. * nextRowset
235. * Advances to the next rowset in a multi-rowset statement handle
236. *
237. * Some database servers support stored procedures that return more than one rowset
238. * (also known as a result set). The nextRowset() method enables you to access the second
239. * and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
240. * different set of columns from the preceding rowset.
241. *
242. * @return boolean Returns TRUE on success or FALSE on failure.
243. */
244. public function nextRowset();
245. /**
246. * rowCount
247. * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
248. * executed by the corresponding object.
249. *
250. * If the last SQL statement executed by the associated Statement object was a SELECT statement,
251. * some databases may return the number of rows returned by that statement. However,
252. * this behaviour is not guaranteed for all databases and should not be
253. * relied on for portable applications.
254. *
255. * @return integer Returns the number of rows.
256. */
257. public function rowCount();
258. /**
259. * setAttribute
260. * Set a statement attribute
261. *
262. * @param integer $attribute
263. * @param mixed $value the value of given attribute
264. * @return boolean Returns TRUE on success or FALSE on failure.
265. */
266. public function setAttribute($attribute, $value);
267. /**
268. * setFetchMode
269. * Set the default fetch mode for this statement
270. *
271. * @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants.
272. * @return boolean Returns 1 on success or FALSE on failure.
273. */
274. public function setFetchMode($mode, $arg1 = null, $arg2 = null);
275. }