Re: cvs: pecl /pdo pdo.c
| From: | Andi Gutmans | Date: | Thu, 24 Mar 2005 01:14:42 +0000 |
| Subject: | Re: cvs: pecl /pdo pdo.c | ||
| References: | 1 | Groups: | php.pecl.cvs |
| Request: | Send a blank email to pecl-cvs+get-2890@lists.php.net to get a copy of this message | ||
As this doesn't have to be high performance, isn't it nicer to use one of the zend_hash_apply() (w/ arguments) functions to traverse the hash and create the array.
Andi
At 10:36 AM 3/22/2005 +0000, Marcus Boerger wrote:
helly Tue Mar 22 05:36:26 2005 EDTModified files:/pecl/pdo pdo.cLog: - Add function pdo_drivers() http://cvs.php.net/diff.php/pecl/pdo/pdo.c?r1=1.46&r2=1.47&ty=u Index: pecl/pdo/pdo.c diff -u pecl/pdo/pdo.c:1.46 pecl/pdo/pdo.c:1.47 --- pecl/pdo/pdo.c:1.46 Tue Mar 22 05:26:51 2005+++ pecl/pdo/pdo.c Tue Mar 22 05:36:25 2005@@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo.c,v 1.46 2005/03/22 10:26:51 helly Exp $ */ +/* $Id: pdo.c,v 1.47 2005/03/22 10:36:25 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -62,8 +62,26 @@ zend_class_entry *pdo_dbh_ce, *pdo_dbstmt_ce, *pdo_row_ce; +/* proto array pdo_drivers() + Return array of available PDO drivers */ +PHP_FUNCTION(pdo_drivers) +{+ HashPosition pos; + pdo_driver_t **pdriver;++ array_init(return_value);++ zend_hash_internal_pointer_reset_ex(&pdo_driver_hash, &pos); + while (SUCCESS == zend_hash_get_current_data_ex(&pdo_driver_hash, (void**)&pdriver, &pos)) { + add_next_index_stringl(return_value, (char*)(*pdriver)->driver_name, (*pdriver)->driver_name_len, 1); + zend_hash_move_forward_ex(&pdo_driver_hash, &pos); + }+} +/* }}} */ + /* {{{ pdo_functions[] */ function_entry pdo_functions[] = {+ PHP_FE(pdo_drivers, NULL) {NULL, NULL, NULL}}; /* }}} */ -- PECL CVS Mailing List To unsubscribe, visit: http://www.php.net/unsub.php