summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xext/pdo/pdo.c9
-rwxr-xr-xext/pdo/pdo_dbh.c2
-rw-r--r--ext/pdo/pdo_sql_parser.c2
-rw-r--r--ext/pdo/pdo_sqlstate.c2
-rwxr-xr-xext/pdo/pdo_stmt.c33
-rwxr-xr-xext/pdo/php_pdo.h2
-rwxr-xr-xext/pdo/php_pdo_driver.h20
-rwxr-xr-xext/pdo/php_pdo_int.h2
-rw-r--r--ext/pdo/php_pdo_sql_parser.h2
9 files changed, 50 insertions, 24 deletions
diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c
index 2e3a24fbc1..9b2daf19bf 100755
--- a/ext/pdo/pdo.c
+++ b/ext/pdo/pdo.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -258,6 +258,13 @@ PHP_MINIT_FUNCTION(pdo)
REGISTER_STRING_CONSTANT("PDO_ERR_NONE", PDO_ERR_NONE, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_NEXT", (long)PDO_FETCH_ORI_NEXT, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_PRIOR", (long)PDO_FETCH_ORI_PRIOR, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_FIRST", (long)PDO_FETCH_ORI_FIRST, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_LAST", (long)PDO_FETCH_ORI_LAST, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_ABS", (long)PDO_FETCH_ORI_ABS, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_REL", (long)PDO_FETCH_ORI_REL, CONST_CS|CONST_PERSISTENT);
+
#if 0
REGISTER_LONG_CONSTANT("PDO_ERR_CANT_MAP", (long)PDO_ERR_CANT_MAP, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_SYNTAX", (long)PDO_ERR_SYNTAX, CONST_CS|CONST_PERSISTENT);
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index b46059954d..09c19191d1 100755
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
index 5c4ee0ac06..26bdf21a2c 100644
--- a/ext/pdo/pdo_sql_parser.c
+++ b/ext/pdo/pdo_sql_parser.c
@@ -4,7 +4,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/pdo/pdo_sqlstate.c b/ext/pdo/pdo_sqlstate.c
index d927d5202f..68bfeb4757 100644
--- a/ext/pdo/pdo_sqlstate.c
+++ b/ext/pdo/pdo_sqlstate.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 825b91b55b..63c64fb5e1 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -403,13 +403,14 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno TSRMLS_DC
}
}
-static int do_fetch_common(pdo_stmt_t *stmt, int do_bind TSRMLS_DC)
+static int do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori,
+ long offset, int do_bind TSRMLS_DC)
{
if (!dispatch_param_event(stmt, PDO_PARAM_EVT_FETCH_PRE TSRMLS_CC)) {
return 0;
}
- if (!stmt->methods->fetcher(stmt TSRMLS_CC)) {
+ if (!stmt->methods->fetcher(stmt, ori, offset TSRMLS_CC)) {
return 0;
}
@@ -452,7 +453,8 @@ static int do_fetch_common(pdo_stmt_t *stmt, int do_bind TSRMLS_DC)
/* perform a fetch. If do_bind is true, update any bound columns.
* If return_value is not null, store values into it according to HOW. */
-static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_fetch_type how TSRMLS_DC)
+static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,
+ enum pdo_fetch_type how, enum pdo_fetch_orientation ori, long offset TSRMLS_DC)
{
enum pdo_fetch_type really_how = how;
@@ -460,7 +462,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
really_how = how = stmt->default_fetch_type;
}
- if (!do_fetch_common(stmt, do_bind TSRMLS_CC)) {
+ if (!do_fetch_common(stmt, ori, offset, do_bind TSRMLS_CC)) {
return 0;
}
@@ -551,19 +553,22 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
return 1;
}
-/* {{{ proto mixed PDOStatement::fetch([int $how = PDO_FETCH_BOTH])
+/* {{{ proto mixed PDOStatement::fetch([int $how = PDO_FETCH_BOTH [, int $orientation [, int $offset]]])
Fetches the next row and returns it, or false if there are no more rows */
static PHP_METHOD(PDOStatement, fetch)
{
long how = PDO_FETCH_USE_DEFAULT;
+ long ori = PDO_FETCH_ORI_NEXT;
+ long off = 0;
pdo_stmt_t *stmt = (pdo_stmt_t*)zend_object_store_get_object(getThis() TSRMLS_CC);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &how)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lll", &how,
+ &ori, &off)) {
RETURN_FALSE;
}
PDO_STMT_CLEAR_ERR();
- if (!do_fetch(stmt, TRUE, return_value, how TSRMLS_CC)) {
+ if (!do_fetch(stmt, TRUE, return_value, how, ori, off TSRMLS_CC)) {
PDO_HANDLE_STMT_ERR();
RETURN_FALSE;
}
@@ -581,7 +586,7 @@ static PHP_METHOD(PDOStatement, fetchSingle)
}
PDO_STMT_CLEAR_ERR();
- if (!do_fetch_common(stmt, TRUE TSRMLS_CC)) {
+ if (!do_fetch_common(stmt, PDO_FETCH_ORI_NEXT, 0, TRUE TSRMLS_CC)) {
PDO_HANDLE_STMT_ERR();
RETURN_FALSE;
}
@@ -604,7 +609,7 @@ static PHP_METHOD(PDOStatement, fetchAll)
PDO_STMT_CLEAR_ERR();
MAKE_STD_ZVAL(data);
- if (!do_fetch(stmt, TRUE, data, how TSRMLS_CC)) {
+ if (!do_fetch(stmt, TRUE, data, how, PDO_FETCH_ORI_NEXT, 0 TSRMLS_CC)) {
FREE_ZVAL(data);
PDO_HANDLE_STMT_ERR();
RETURN_FALSE;
@@ -614,7 +619,7 @@ static PHP_METHOD(PDOStatement, fetchAll)
do {
add_next_index_zval(return_value, data);
MAKE_STD_ZVAL(data);
- } while (do_fetch(stmt, TRUE, data, how TSRMLS_CC));
+ } while (do_fetch(stmt, TRUE, data, how, PDO_FETCH_ORI_NEXT, 0 TSRMLS_CC));
FREE_ZVAL(data);
}
/* }}} */
@@ -1257,7 +1262,8 @@ static void pdo_stmt_iter_move_forwards(zend_object_iterator *iter TSRMLS_DC)
MAKE_STD_ZVAL(I->fetch_ahead);
- if (!do_fetch(I->stmt, TRUE, I->fetch_ahead, PDO_FETCH_USE_DEFAULT TSRMLS_CC)) {
+ if (!do_fetch(I->stmt, TRUE, I->fetch_ahead, PDO_FETCH_USE_DEFAULT,
+ PDO_FETCH_ORI_NEXT, 0 TSRMLS_CC)) {
pdo_stmt_t *stmt = I->stmt; /* for PDO_HANDLE_STMT_ERR() */
PDO_HANDLE_STMT_ERR();
@@ -1292,7 +1298,8 @@ zend_object_iterator *pdo_stmt_iter_get(zend_class_entry *ce, zval *object TSRML
stmt->refcount++;
MAKE_STD_ZVAL(I->fetch_ahead);
- if (!do_fetch(I->stmt, TRUE, I->fetch_ahead, PDO_FETCH_USE_DEFAULT TSRMLS_CC)) {
+ if (!do_fetch(I->stmt, TRUE, I->fetch_ahead, PDO_FETCH_USE_DEFAULT,
+ PDO_FETCH_ORI_NEXT, 0 TSRMLS_CC)) {
PDO_HANDLE_STMT_ERR();
I->key = (ulong)-1;
FREE_ZVAL(I->fetch_ahead);
diff --git a/ext/pdo/php_pdo.h b/ext/pdo/php_pdo.h
index d9ef7130be..57c71374f8 100755
--- a/ext/pdo/php_pdo.h
+++ b/ext/pdo/php_pdo.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h
index 87c2b0f187..ed853f49ed 100755
--- a/ext/pdo/php_pdo_driver.h
+++ b/ext/pdo/php_pdo_driver.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -35,7 +35,7 @@ struct pdo_bound_param_data;
# define FALSE 0
#endif
-#define PDO_DRIVER_API 20050105
+#define PDO_DRIVER_API 20050111
enum pdo_param_type {
PDO_PARAM_NULL,
@@ -60,6 +60,16 @@ enum pdo_fetch_type {
PDO_FETCH__MAX /* must be last */
};
+/* fetch orientation for scrollable cursors */
+enum pdo_fetch_orientation {
+ PDO_FETCH_ORI_NEXT, /* default: fetch the next available row */
+ PDO_FETCH_ORI_PRIOR, /* scroll back to prior row and fetch that */
+ PDO_FETCH_ORI_FIRST, /* scroll to the first row and fetch that */
+ PDO_FETCH_ORI_LAST, /* scroll to the last row and fetch that */
+ PDO_FETCH_ORI_ABS, /* scroll to an absolute numbered row and fetch that */
+ PDO_FETCH_ORI_REL, /* scroll relative to the current row, and fetch that */
+};
+
enum pdo_attribute_type {
PDO_ATTR_AUTOCOMMIT, /* use to turn on or off auto-commit mode */
PDO_ATTR_SCROLL, /* ask for a scrollable cursor (when you prepare()) */
@@ -254,8 +264,10 @@ typedef int (*pdo_stmt_dtor_func)(pdo_stmt_t *stmt TSRMLS_DC);
typedef int (*pdo_stmt_execute_func)(pdo_stmt_t *stmt TSRMLS_DC);
/* causes the next row in the set to be fetched; indicates if there are no
- * more rows */
-typedef int (*pdo_stmt_fetch_func)(pdo_stmt_t *stmt TSRMLS_DC);
+ * more rows. The ori and offset params modify which row should be returned,
+ * if the stmt represents a scrollable cursor */
+typedef int (*pdo_stmt_fetch_func)(pdo_stmt_t *stmt,
+ enum pdo_fetch_orientation ori, long offset TSRMLS_DC);
/* queries information about the type of a column, by index (0 based).
* Driver should populate stmt->columns[colno] with appropriate info */
diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h
index 3db761e6c6..68cb8a33a4 100755
--- a/ext/pdo/php_pdo_int.h
+++ b/ext/pdo/php_pdo_int.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/pdo/php_pdo_sql_parser.h b/ext/pdo/php_pdo_sql_parser.h
index 4bb92cc212..2c3850c009 100644
--- a/ext/pdo/php_pdo_sql_parser.h
+++ b/ext/pdo/php_pdo_sql_parser.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |