/* True global resources - no need for thread safety here */
/* the registry of PDO drivers */
-static HashTable pdo_driver_hash;
+HashTable pdo_driver_hash;
/* we use persistent resources for the driver connection stuff */
static int le_ppdo;
"PDO persistent database", module_number);
INIT_CLASS_ENTRY(ce, "PDOException", NULL);
- pdo_exception_ce = zend_register_internal_class_ex(&ce, php_pdo_get_exception_base(0 TSRMLS_CC), NULL TSRMLS_CC);
+#if can_handle_soft_dependency_on_SPL && defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
+ pdo_exception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException, NULL TSRMLS_CC);
+#else
+ pdo_exception_ce = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
+#endif
zend_declare_property_null(pdo_exception_ce, "errorInfo", sizeof("errorInfo")-1, ZEND_ACC_PUBLIC TSRMLS_CC);
pdo_dbh_init(TSRMLS_C);
RETURN_LONG(dbh->error_mode);
case PDO_ATTR_DRIVER_NAME:
- RETURN_STRINGL(dbh->driver->driver_name, dbh->driver->driver_name_len, 1);
+ RETURN_STRINGL((char*)dbh->driver->driver_name, dbh->driver->driver_name_len, 1);
case PDO_ATTR_STATEMENT_CLASS:
array_init(return_value);
}
/* }}} */
+/* {{{ proto array pdo_drivers()
+ Return array of available PDO drivers */
+static PHP_METHOD(PDO, getAvailableDrivers)
+{
+ 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);
+ }
+}
+/* }}} */
+
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, errorCode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, errorInfo, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, getAttribute, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(PDO, quote, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, __wakeup, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(PDO, __sleep, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
- PHP_ME(PDO, quote, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(PDO, getAvailableDrivers, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
{NULL, NULL, NULL}
};