From c4ca0f3378c81b6dad9159bf4b7c966148127f9d Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 18 May 2004 19:30:22 +0000 Subject: [PATCH] Give user a nice message when PDO isn't initialized prior to a driver. --- ext/pdo/pdo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c index 9730b00a674..81aa2e83e7d 100755 --- a/ext/pdo/pdo.c +++ b/ext/pdo/pdo.c @@ -90,7 +90,10 @@ PDO_API int php_pdo_register_driver(pdo_driver_t *driver) if (driver->api_version != PDO_DRIVER_API) return FAILURE; - printf("registering PDO driver %s\n", driver->driver_name); + if (!zend_hash_exists(&module_registry, "pdo", sizeof("pdo"))) { + zend_error(E_ERROR, "You MUST load PDO before loading any PDO drivers"); + return FAILURE; /* NOTREACHED */ + } return zend_hash_add(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len, (void**)&driver, sizeof(driver), NULL); @@ -98,6 +101,10 @@ PDO_API int php_pdo_register_driver(pdo_driver_t *driver) PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver) { + if (!zend_hash_exists(&module_registry, "pdo", sizeof("pdo"))) { + return; + } + zend_hash_del(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len); }