summaryrefslogtreecommitdiff
path: root/ext/pdo/php_pdo_driver.h
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2005-07-03 03:49:44 +0000
committerWez Furlong <wez@php.net>2005-07-03 03:49:44 +0000
commitd4a158260b77e6d7590bfbd63b32b812f4851026 (patch)
treef4db02b9e6f2e62c765c9280a166eda9a740235d /ext/pdo/php_pdo_driver.h
parent75cfa5c2e0f66add8422770ac2d444a6b050c32e (diff)
downloadphp-git-d4a158260b77e6d7590bfbd63b32b812f4851026.tar.gz
Add PDO_FETCH_NAMED; closes PECL #4641 by providing a way to access columns
by name, even when multiple columns have the same name: $sql = "SELECT 1 a, 2 a, 3 b, 4 c, 5 d, 6 c, 7 a"; echo "$sql\n"; print_r($db->query($sql)->fetchAll(PDO_FETCH_NAMED)); Array ( [0] => Array ( [a] => Array ( [0] => 1 [1] => 2 [2] => 7 ) [b] => 3 [c] => Array ( [0] => 4 [1] => 6 ) [d] => 5 ) ) Also added two new attributes for use at prepare time; PDO_ATTR_FETCH_TABLE_NAMES and PDO_ATTR_FETCH_CATALOG_NAMES instruct the driver that the names of the columns that they return to PDO should include the table and catalog names respectively. Both attributes may be used together or independently. The catalog, table and column name components should be separated by a . character.
Diffstat (limited to 'ext/pdo/php_pdo_driver.h')
-rwxr-xr-xext/pdo/php_pdo_driver.h23
1 files changed, 4 insertions, 19 deletions
diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h
index 4d86cdeb59..53cf2bcc8f 100755
--- a/ext/pdo/php_pdo_driver.h
+++ b/ext/pdo/php_pdo_driver.h
@@ -44,7 +44,7 @@ PDO_API char *php_pdo_int64_to_str(pdo_int64_t i64 TSRMLS_DC);
# define FALSE 0
#endif
-#define PDO_DRIVER_API 20050610
+#define PDO_DRIVER_API 20050702
enum pdo_param_type {
PDO_PARAM_NULL,
@@ -89,6 +89,7 @@ enum pdo_fetch_type {
PDO_FETCH_CLASS, /* create an instance of named class, call ctor and set properties */
PDO_FETCH_INTO, /* fetch row into an existing object */
PDO_FETCH_FUNC, /* fetch into function and return its result */
+ PDO_FETCH_NAMED, /* like PDO_FETCH_ASSOC, but can handle duplicate names */
PDO_FETCH__MAX /* must be last */
};
@@ -123,6 +124,8 @@ enum pdo_attribute_type {
PDO_ATTR_ORACLE_NULLS, /* convert empty strings to NULL */
PDO_ATTR_PERSISTENT, /* pconnect style connection */
PDO_ATTR_STATEMENT_CLASS, /* array(classname, array(ctor_args)) to specify the class of the constructed statement */
+ PDO_ATTR_FETCH_TABLE_NAMES, /* include table names in the column names, where available */
+ PDO_ATTR_FETCH_CATALOG_NAMES, /* include the catalog/db name names in the column names, where available */
/* this defines the start of the range for driver specific options.
* Drivers should define their own attribute constants beginning with this
@@ -156,24 +159,6 @@ typedef char pdo_error_type[6]; /* SQLSTATE */
#define PDO_ERR_NONE "00000"
-#if 0
-/* generic error code values.
- * Don't want to go overboard with these.
- * */
-#define PDO_ERR_SYNTAX "42000"
-#define PDO_ERR_CONSTRAINT "23000"
-#define PDO_ERR_NOT_FOUND ""
-#define PDO_ERR_ALREADY_EXISTS,
-#define PDO_ERR_NOT_IMPLEMENTED,
-#define PDO_ERR_MISMATCH,
-#define PDO_ERR_TRUNCATED,
-#define PDO_ERR_DISCONNECTED,
-#define PDO_ERR_NO_PERM,
-
- PDO_ERR_CANT_MAP /* no way to map native error to the generic
- * codes; consult the native error for more info */
-};
-#endif
enum pdo_error_mode {
PDO_ERRMODE_SILENT, /* just set error codes */