Skip to content

Commit a1cd804

Browse files
committed
Attempt php#1
1 parent bcbdce9 commit a1cd804

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

ext/pdo/pdo_dbh.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
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+
4043
void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp) /* {{{ */
4144
{
4245
pdo_error_type *pdo_err = &dbh->error_code;

ext/pdo/php_pdo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ 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+
3038
#ifdef PHP_WIN32
3139
# if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO))
3240
# define PDO_API __declspec(dllexport)

ext/pdo_sqlite/pdo_sqlite.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ PHP_MINIT_FUNCTION(pdo_sqlite)
8787
// The Reflection extension manges to set serialize and unserialize *before* calling
8888
// zend_register_internal_class(). I couldn't make that work (something to do with
8989
// pointers/references?) so have had to put them after.
90-
pdo_dbh_sqlite_ptr = zend_register_internal_class(&ce_sqlite); // @TODO Add a second parameter with name of PDO ptr
90+
pdo_dbh_sqlite_ptr = zend_register_internal_class(&ce_sqlite, pdo_pdh_ce); // @TODO Second parameter doesn't resolve
9191
pdo_dbh_sqlite_ptr->serialize = zend_class_serialize_deny;
9292
pdo_dbh_sqlite_ptr->unserialize = zend_class_unserialize_deny;
9393
zend_declare_property_string(pdo_dbh_sqlite_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
@@ -114,3 +114,20 @@ PHP_MINFO_FUNCTION(pdo_sqlite)
114114
php_info_print_table_end();
115115
}
116116
/* }}} */
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+
///* }}} */

ext/pdo_sqlite/php_pdo_sqlite.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ PHP_RSHUTDOWN_FUNCTION(pdo_sqlite);
3636
PHP_MINFO_FUNCTION(pdo_sqlite);
3737

3838
#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);

0 commit comments

Comments
 (0)