Skip to content

Commit 90a9c20

Browse files
committed
Attempt php#2 based on SimpleXML which WORKS!
1 parent a1cd804 commit 90a9c20

File tree

4 files changed

+11
-33
lines changed

4 files changed

+11
-33
lines changed

ext/pdo/pdo_dbh.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737

3838
static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value);
3939

40-
/* Class entry pointers */
41-
PHPAPI zend_class_entry *pdo_dbh_ce;
42-
4340
void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp) /* {{{ */
4441
{
4542
pdo_error_type *pdo_err = &dbh->error_code;

ext/pdo/php_pdo.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ extern zend_module_entry pdo_module_entry;
2727
#include "php_version.h"
2828
#define PHP_PDO_VERSION PHP_VERSION
2929

30-
// Copied from php_reflection.h
31-
BEGIN_EXTERN_C()
32-
33-
/* Class entry pointers */
34-
extern PHPAPI zend_class_entry *pdo_dbh_ce;
35-
36-
END_EXTERN_C()
37-
3830
#ifdef PHP_WIN32
3931
# if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO))
4032
# define PDO_API __declspec(dllexport)

ext/pdo_sqlite/pdo_sqlite.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
/* Class entry pointers */
3434
PHPAPI zend_class_entry *pdo_dbh_sqlite_ptr;
35+
PHPAPI zend_class_entry *ce_pdo;
3536

3637
/* {{{ pdo_sqlite_functions[] */
3738
static const zend_function_entry pdo_sqlite_functions[] = {
@@ -82,12 +83,19 @@ PHP_MINIT_FUNCTION(pdo_sqlite)
8283
REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_READONLY_STATEMENT", (zend_long)PDO_SQLITE_ATTR_READONLY_STATEMENT);
8384
REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_EXTENDED_RESULT_CODES", (zend_long)PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES);
8485

86+
zend_class_entry *pce;
8587
zend_class_entry ce_sqlite;
88+
89+
if ((pce = zend_hash_str_find_ptr(CG(class_table), "pdo", sizeof("PDO") - 1)) == NULL) {
90+
return SUCCESS; /* SimpleXML must be initialized before */
91+
}
92+
93+
ce_pdo = pce;
8694
INIT_CLASS_ENTRY(ce_sqlite, "PDOSQLite", pdo_sqlite_functions);
8795
// The Reflection extension manges to set serialize and unserialize *before* calling
8896
// zend_register_internal_class(). I couldn't make that work (something to do with
8997
// pointers/references?) so have had to put them after.
90-
pdo_dbh_sqlite_ptr = zend_register_internal_class(&ce_sqlite, pdo_pdh_ce); // @TODO Second parameter doesn't resolve
98+
pdo_dbh_sqlite_ptr = zend_register_internal_class_ex(&ce_sqlite, ce_pdo); // @TODO Second parameter doesn't resolve
9199
pdo_dbh_sqlite_ptr->serialize = zend_class_serialize_deny;
92100
pdo_dbh_sqlite_ptr->unserialize = zend_class_unserialize_deny;
93101
zend_declare_property_string(pdo_dbh_sqlite_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
@@ -113,21 +121,4 @@ PHP_MINFO_FUNCTION(pdo_sqlite)
113121
php_info_print_table_row(2, "SQLite Library", sqlite3_libversion());
114122
php_info_print_table_end();
115123
}
116-
/* }}} */
117-
118-
///* {{{ spl_register_sub_class */
119-
//PHPAPI void spl_register_sub_class(zend_class_entry ** ppce, zend_class_entry * parent_ce, char * class_name, void *obj_ctor, const zend_function_entry * function_list)
120-
//{
121-
// zend_class_entry ce;
122-
//
123-
// INIT_CLASS_ENTRY_EX(ce, class_name, strlen(class_name), function_list);
124-
// *ppce = zend_register_internal_class_ex(&ce, parent_ce);
125-
//
126-
// /* entries changed by initialize */
127-
// if (obj_ctor) {
128-
// (*ppce)->create_object = obj_ctor;
129-
// } else {
130-
// (*ppce)->create_object = parent_ce->create_object;
131-
// }
132-
//}
133-
///* }}} */
124+
/* }}} */

ext/pdo_sqlite/php_pdo_sqlite.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,4 @@ PHP_RINIT_FUNCTION(pdo_sqlite);
3535
PHP_RSHUTDOWN_FUNCTION(pdo_sqlite);
3636
PHP_MINFO_FUNCTION(pdo_sqlite);
3737

38-
#endif /* PHP_PDO_SQLITE_H */
39-
40-
void spl_register_sub_class(zend_class_entry ** ppce, zend_class_entry * parent_ce, char * class_name, create_object_func_t ctor, const zend_function_entry * function_list);
38+
#endif /* PHP_PDO_SQLITE_H */

0 commit comments

Comments
 (0)