Skip to content

Commit bcbdce9

Browse files
committed
Add a PDOSQLite class that compiles and is accessible from PHP
1 parent f3e6b12 commit bcbdce9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ext/pdo_sqlite/pdo_sqlite.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include "php_pdo_sqlite.h"
2929
#include "php_pdo_sqlite_int.h"
3030
#include "zend_exceptions.h"
31+
#include "zend_interfaces.h"
32+
33+
/* Class entry pointers */
34+
PHPAPI zend_class_entry *pdo_dbh_sqlite_ptr;
3135

3236
/* {{{ pdo_sqlite_functions[] */
3337
static const zend_function_entry pdo_sqlite_functions[] = {
@@ -78,6 +82,16 @@ PHP_MINIT_FUNCTION(pdo_sqlite)
7882
REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_READONLY_STATEMENT", (zend_long)PDO_SQLITE_ATTR_READONLY_STATEMENT);
7983
REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_EXTENDED_RESULT_CODES", (zend_long)PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES);
8084

85+
zend_class_entry ce_sqlite;
86+
INIT_CLASS_ENTRY(ce_sqlite, "PDOSQLite", pdo_sqlite_functions);
87+
// The Reflection extension manges to set serialize and unserialize *before* calling
88+
// zend_register_internal_class(). I couldn't make that work (something to do with
89+
// 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
91+
pdo_dbh_sqlite_ptr->serialize = zend_class_serialize_deny;
92+
pdo_dbh_sqlite_ptr->unserialize = zend_class_unserialize_deny;
93+
zend_declare_property_string(pdo_dbh_sqlite_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
94+
8195
return php_pdo_register_driver(&pdo_sqlite_driver);
8296
}
8397
/* }}} */

0 commit comments

Comments
 (0)