osdir.com
mailing list archive

Subject: cvs: pecl /pdo pdo_dbh.c php_pdo_driver.h - msg#00182

List: php.pecl.cvs

Date: Prev Next Index Thread: Prev Next Index
helly Sat Mar 18 23:10:40 2006 UTC

Modified files:
/pecl/pdo pdo_dbh.c php_pdo_driver.h
Log:
- Add PDO::setDEfaultFetchMode() (Pierre)

http://cvs.php.net/viewcvs.cgi/pecl/pdo/pdo_dbh.c?r1=1.116&r2=1.117&diff_format=u
Index: pecl/pdo/pdo_dbh.c
diff -u pecl/pdo/pdo_dbh.c:1.116 pecl/pdo/pdo_dbh.c:1.117
--- pecl/pdo/pdo_dbh.c:1.116 Mon Mar 6 10:00:41 2006
+++ pecl/pdo/pdo_dbh.c Sat Mar 18 23:10:40 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: pdo_dbh.c,v 1.116 2006/03/06 10:00:41 helly Exp $ */
+/* $Id: pdo_dbh.c,v 1.117 2006/03/18 23:10:40 helly Exp $ */

/* The PDO Database Handle Class */

@@ -391,6 +391,22 @@
}
/* }}} */

+/* {{{ proto object PDO::setDefaultFetchMode(PDOStatement::setFetchMode())
+ Set the default fetch mode for this connection */
+static PHP_METHOD(PDO, setDefaultFetchMode)
+{
+ pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
+ long mode;
+
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
&mode)) {
+ RETURN_FALSE;
+ }
+
+ PDO_CONSTRUCT_CHECK;
+ dbh->default_fetch_type = mode;
+}
+/* }}} */
+
static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object,
zend_class_entry *dbstmt_ce, zval *ctor_args TSRMLS_DC) /* {{{ */
{
if (ctor_args) {
@@ -964,7 +980,13 @@
/* unconditionally keep this for later reference */
stmt->query_string = estrndup(statement, statement_len);
stmt->query_stringlen = statement_len;
- stmt->default_fetch_type = PDO_FETCH_BOTH;
+
+ if (ZEND_NUM_ARGS() == 1 && dbh->default_fetch_type) {
+ stmt->default_fetch_type = dbh->default_fetch_type;
+ } else {
+ stmt->default_fetch_type = PDO_FETCH_BOTH;
+ }
+
stmt->active_query_string = stmt->query_string;
stmt->active_query_stringlen = statement_len;
stmt->dbh = dbh;
@@ -1071,8 +1093,9 @@

zend_function_entry pdo_dbh_functions[] = {
ZEND_MALIAS(PDO, __construct, dbh_constructor, NULL,
ZEND_ACC_PUBLIC)
- PHP_ME(PDO, prepare, NULL,
ZEND_ACC_PUBLIC)
- PHP_ME(PDO, beginTransaction,NULL,
ZEND_ACC_PUBLIC)
+ PHP_ME(PDO, prepare, NULL,
ZEND_ACC_PUBLIC)
+ PHP_ME(PDO, setDefaultFetchMode, NULL,
ZEND_ACC_PUBLIC)
+ PHP_ME(PDO, beginTransaction, NULL,
ZEND_ACC_PUBLIC)
PHP_ME(PDO, commit, NULL,
ZEND_ACC_PUBLIC)
PHP_ME(PDO, rollBack, NULL,
ZEND_ACC_PUBLIC)
PHP_ME(PDO, setAttribute, NULL,
ZEND_ACC_PUBLIC)
http://cvs.php.net/viewcvs.cgi/pecl/pdo/php_pdo_driver.h?r1=1.76&r2=1.77&diff_format=u
Index: pecl/pdo/php_pdo_driver.h
diff -u pecl/pdo/php_pdo_driver.h:1.76 pecl/pdo/php_pdo_driver.h:1.77
--- pecl/pdo/php_pdo_driver.h:1.76 Fri Feb 24 16:04:13 2006
+++ pecl/pdo/php_pdo_driver.h Sat Mar 18 23:10:40 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: php_pdo_driver.h,v 1.76 2006/02/24 16:04:13 helly Exp $ */
+/* $Id: php_pdo_driver.h,v 1.77 2006/03/18 23:10:40 helly Exp $ */

#ifndef PHP_PDO_DRIVER_H
#define PHP_PDO_DRIVER_H
@@ -477,6 +477,9 @@

enum pdo_case_conversion native_case, desired_case;

+ /* defaults for fetches */
+ enum pdo_fetch_type default_fetch_type;
+
/* persistent hash key associated with this handle */
const char *persistent_id;
int persistent_id_len;



Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

cvs: pecl /pdo pdo_stmt.c

helly Sat Mar 18 23:09:48 2006 UTC Modified files: /pecl/pdo pdo_stmt.c Log: - Simplify http://cvs.php.net/viewcvs.cgi/pecl/pdo/pdo_stmt.c?r1=1.151&r2=1.152&diff_format=u Index: pecl/pdo/pdo_stmt.c diff -u pecl/pdo/pdo_stmt.c:1.151 pecl/pdo/pdo_stmt.c:1.152 --- pecl/pdo/pdo_stmt.c:1.151 Sat Mar 18 22:25:29 2006 +++ pecl/pdo/pdo_stmt.c Sat Mar 18 23:09:47 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_stmt.c,v 1.151 2006/03/18 22:25:29 tony2001 Exp $ */ +/* $Id: pdo_stmt.c,v 1.152 2006/03/18 23:09:47 helly Exp $ */ /* The PDO Statement Handle Class */ @@ -2120,10 +2120,9 @@ int i; struct pdo_column_data *cols = stmt->columns; - for (i = 0; i < stmt->column_count; i++) { - if (cols[i].name) { + for (i = stmt->column_count; i >= 0;) { + if (cols[--i].name) { efree(cols[i].name); - cols[i].name = NULL; } } efree(stmt->columns);

Next Message by Date: click to view message preview

cvs: pecl /pdo/tests bug_34687.phpt

helly Sat Mar 18 23:13:43 2006 UTC Modified files: /pecl/pdo/tests bug_34687.phpt Log: - Add test http://cvs.php.net/viewcvs.cgi/pecl/pdo/tests/bug_34687.phpt?r1=1.1&r2=1.2&diff_format=u Index: pecl/pdo/tests/bug_34687.phpt diff -u /dev/null pecl/pdo/tests/bug_34687.phpt:1.2 --- /dev/null Sat Mar 18 23:13:43 2006 +++ pecl/pdo/tests/bug_34687.phpt Sat Mar 18 23:13:43 2006 @@ -0,0 +1,32 @@ +--TEST-- +PDO Common: PHP Bug #34687: query doesn't return error information +--SKIPIF-- +<?php # vim:ft=php +if (!extension_loaded('pdo')) die('skip'); +$dir = getenv('REDIR_TEST_DIR'); +if (false == $dir) die('skip no driver'); +require_once $dir . 'pdo_test.inc'; +PDOTest::skip(); +?> +--FILE-- +<?php +if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/'); +require getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; +$db = PDOTest::factory(); + +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); +$x = $db->query("UPDATE non_existent_pdo_test_table set foo = 'bar'"); + +var_dump($x); +$code = $db->errorCode(); +if ($code !== '00000' && strlen($code)) { + echo "OK: $code\n"; +} else { + echo "ERR: $code\n"; + print_r($db->errorInfo()); +} + +?> +--EXPECTF-- +bool(false) +OK: %s

Previous Message by Thread: click to view message preview

cvs: pecl /pdo pdo_stmt.c

helly Sat Mar 18 23:09:48 2006 UTC Modified files: /pecl/pdo pdo_stmt.c Log: - Simplify http://cvs.php.net/viewcvs.cgi/pecl/pdo/pdo_stmt.c?r1=1.151&r2=1.152&diff_format=u Index: pecl/pdo/pdo_stmt.c diff -u pecl/pdo/pdo_stmt.c:1.151 pecl/pdo/pdo_stmt.c:1.152 --- pecl/pdo/pdo_stmt.c:1.151 Sat Mar 18 22:25:29 2006 +++ pecl/pdo/pdo_stmt.c Sat Mar 18 23:09:47 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_stmt.c,v 1.151 2006/03/18 22:25:29 tony2001 Exp $ */ +/* $Id: pdo_stmt.c,v 1.152 2006/03/18 23:09:47 helly Exp $ */ /* The PDO Statement Handle Class */ @@ -2120,10 +2120,9 @@ int i; struct pdo_column_data *cols = stmt->columns; - for (i = 0; i < stmt->column_count; i++) { - if (cols[i].name) { + for (i = stmt->column_count; i >= 0;) { + if (cols[--i].name) { efree(cols[i].name); - cols[i].name = NULL; } } efree(stmt->columns);

Next Message by Thread: click to view message preview

cvs: pecl /pdo pdo_dbh.c php_pdo_driver.h

helly Mon Mar 20 20:54:34 2006 UTC Modified files: /pecl/pdo pdo_dbh.c php_pdo_driver.h Log: - Added PDO_ATTR_DEFAULT_FETCH_MODE which controls the default fetch mode http://cvs.php.net/viewcvs.cgi/pecl/pdo/pdo_dbh.c?r1=1.124&r2=1.125&diff_format=u Index: pecl/pdo/pdo_dbh.c diff -u pecl/pdo/pdo_dbh.c:1.124 pecl/pdo/pdo_dbh.c:1.125 --- pecl/pdo/pdo_dbh.c:1.124 Sun Mar 19 22:57:47 2006 +++ pecl/pdo/pdo_dbh.c Mon Mar 20 20:54:34 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_dbh.c,v 1.124 2006/03/19 22:57:47 tony2001 Exp $ */ +/* $Id: pdo_dbh.c,v 1.125 2006/03/20 20:54:34 helly Exp $ */ /* The PDO Database Handle Class */ @@ -723,6 +723,15 @@ dbh->oracle_nulls = Z_LVAL_P(value); return SUCCESS; + case PDO_ATTR_DEFAULT_FETCH_MODE: + convert_to_long(value); + if (Z_LVAL_P(value) == PDO_FETCH_USE_DEFAULT) { + pdo_raise_impl_error(dbh, NULL, "HY000", "invalid fetch mode type" TSRMLS_CC); + return FAILURE; + } + dbh->default_fetch_type = Z_LVAL_P(value); + return SUCCESS; + case PDO_ATTR_STRINGIFY_FETCHES: convert_to_long(value); dbh->stringify = Z_LVAL_P(value) ? 1 : 0; @@ -869,6 +878,9 @@ add_next_index_zval(return_value, dbh->def_stmt_ctor_args); } return; + case PDO_ATTR_DEFAULT_FETCH_MODE: + RETURN_LONG(dbh->default_fetch_type); + } if (!dbh->methods->get_attribute) { @@ -1308,6 +1320,7 @@ REGISTER_PDO_CLASS_CONST_LONG("ATTR_DRIVER_NAME", (long)PDO_ATTR_DRIVER_NAME); REGISTER_PDO_CLASS_CONST_LONG("ATTR_STRINGIFY_FETCHES",(long)PDO_ATTR_STRINGIFY_FETCHES); REGISTER_PDO_CLASS_CONST_LONG("ATTR_MAX_COLUMN_LEN",(long)PDO_ATTR_MAX_COLUMN_LEN); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_DEFAULT_FETCH_MODE",(long)PDO_ATTR_DEFAULT_FETCH_MODE); REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_SILENT", (long)PDO_ERRMODE_SILENT); REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_WARNING", (long)PDO_ERRMODE_WARNING); http://cvs.php.net/viewcvs.cgi/pecl/pdo/php_pdo_driver.h?r1=1.78&r2=1.79&diff_format=u Index: pecl/pdo/php_pdo_driver.h diff -u pecl/pdo/php_pdo_driver.h:1.78 pecl/pdo/php_pdo_driver.h:1.79 --- pecl/pdo/php_pdo_driver.h:1.78 Sat Mar 18 23:35:34 2006 +++ pecl/pdo/php_pdo_driver.h Mon Mar 20 20:54:34 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo_driver.h,v 1.78 2006/03/18 23:35:34 helly Exp $ */ +/* $Id: php_pdo_driver.h,v 1.79 2006/03/20 20:54:34 helly Exp $ */ #ifndef PHP_PDO_DRIVER_H #define PHP_PDO_DRIVER_H @@ -130,6 +130,7 @@ PDO_ATTR_DRIVER_NAME, /* name of the driver (as used in the constructor) */ PDO_ATTR_STRINGIFY_FETCHES, /* converts integer/float types to strings during fetch */ PDO_ATTR_MAX_COLUMN_LEN, /* make database calculate maximum length of data found in a column */ + PDO_ATTR_DEFAULT_FETCH_MODE, /* Set the default fetch mode */ /* this defines the start of the range for driver specific options. * Drivers should define their own attribute constants beginning with this
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by