/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author:Alan Knowles | +----------------------------------------------------------------------+ */ /* $Id: php_pdo_mysql.h,v 1.2 2004/05/19 14:23:59 edink Exp $ */ #ifndef PHP_DBDO_H #define PHP_DBDO_H extern zend_module_entry dbdo_module_entry; #define phpext_dbdo_ptr &dbdo_module_entry #ifdef PHP_WIN32 #define PHP_DBDO_API __declspec(dllexport) #else #define PHP_DBDO_API #endif #ifdef ZTS #include "TSRM.h" #endif #include "pdo/php_pdo.h" #include "pdo/php_pdo_driver.h" #include "ext/standard/php_smart_str.h" #include "main/snprintf.h" #include "Zend/zend_execute.h" #include "Zend/zend_exceptions.h" #define DBDO_DEBUG0(lvl,string) if (DBDO_G(debugLevel) & lvl) { php_error(E_WARNING, "DBDO:(Debug) " string); } #define DBDO_DEBUG(lvl,string, arg) if (DBDO_G(debugLevel) & lvl) { php_error(E_WARNING, "DBDO:(Debug) " string, arg); } #define DBDO_DEBUG2(lvl,string, arg1,arg2) if (DBDO_G(debugLevel) & lvl) { php_error(E_WARNING, "DBDO:(Debug) " string, arg1,arg2); } #define DBDO_DEBUG3(lvl,string, arg1,arg2,arg3) if (DBDO_G(debugLevel) & lvl) { php_error(E_WARNING, "DBDO:(Debug) " string, arg1,arg2,arg3); } #define DBDO_DEBUG4(lvl,string, arg1,arg2,arg3,arg4) if (DBDO_G(debugLevel) & lvl) { php_error(E_WARNING, "DBDO:(Debug) " string, arg1,arg2,arg3,arg4); } #define DBDO_QUERY_BUILD_DELETE 0 #define DBDO_QUERY_BUILD_SELECT 1 #define DBDO_QUERY_BUILD_UPDATE 2 static void dbdo_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC); static int dbdo_property_has(zval *object, zval *member, int check_empty TSRMLS_DC); static zval * dbdo_property_read(zval *object, zval *member, int type TSRMLS_DC); static HashTable * dbdo_properties_get(zval *object TSRMLS_DC); static void dbdo_property_write(zval *object, zval *member, zval *value TSRMLS_DC); static zend_object_value dbdo_clone(zval *zobject TSRMLS_DC); PHP_DBDO_API zend_object_value dbdo_objects_exception_new(zend_class_entry *class_type TSRMLS_DC); PHP_DBDO_API zend_object_value dbdo_objects_new(zend_class_entry *class_type TSRMLS_DC); zend_class_entry *dbdo_class_entry_ce, *dbdo_class_entry_exception_ce; typedef struct { char *native_type_name; int abstract_type; int abstract_flags; } dbdo_column_data; typedef struct { char *dsn; /* dsn to use. */ char *name; /* name of table -- still need free policy*/ struct pdo_column_data *schema; /* datamodel schema for this table */ int schema_len; /* datamodel schema for this table */ char *sequenceColumn; /* this tables column who's a sequence */ zend_bool sequenceIsNative; /* is it native or emulated sequences */ zend_bool sequenceAssigned; /* has a guess or assignment been made? */ char *sequenceName; /* the name of the sequence (eg. for nextval lookup) */ int keys_len; /* number of keys */ char **keys; /* array of keys */ } dbdo_table; typedef struct { char *dsn; /* (alias name) */ char *connect_dsn; char *username; char *password; char *driver; char *description; char *require_path; char *class_name; char *links; zend_bool lowercase_columns; zend_bool quote_identifiers; } dbdo_config; typedef struct { int refcount; char *where; char *groupBy; char *orderBy; char *having; long limit_from; long limit_qty; zend_bool limit_use; char *data_select; /* using ? */ /* join? */ } dbdo_condition; /* the query conditions.. */ typedef struct { zend_object zo; pdo_dbh_t *con; /* database connection - we can free this in one go - just null on destruct.. */ int row_id; /* active row */ HashTable *result; /* not sure yet */ dbdo_table *table; dbdo_condition *condition; /* conditions builder-- still need free policy */ HashTable *row_cache; HashTable *visable_hash; HashTable *assigned_hash; int row_cached; } dbdo_object; /* extends zend_object */ PHP_MINIT_FUNCTION(dbdo); PHP_MSHUTDOWN_FUNCTION(dbdo); PHP_RINIT_FUNCTION(dbdo); PHP_RSHUTDOWN_FUNCTION(dbdo); PHP_MINFO_FUNCTION(dbdo); PHP_METHOD(dbdo,__construct); PHP_METHOD(dbdo,config); PHP_METHOD(dbdo,factory); PHP_METHOD(dbdo,reproduce); PHP_METHOD(dbdo,debugLevel); PHP_METHOD(dbdo,get); /*PHP_METHOD(dbdo,fetch); PHP_METHOD(dbdo,fetchAll); PHP_METHOD(dbdo,count); PHP_METHOD(dbdo,insert); PHP_METHOD(dbdo,update); PHP_METHOD(dbdo,delete); PHP_METHOD(dbdo,query); PHP_METHOD(dbdo,toArray); PHP_METHOD(dbdo,assignFrom); PHP_METHOD(dbdo,valueSet); PHP_METHOD(dbdo,valueGet); */ /* Information - set/get */ //PHP_METHOD(dbdo,sequenceKey); //PHP_METHOD(dbdo,keys); PHP_METHOD(dbdo,schema); PHP_METHOD(dbdo,info); /* query modification */ /* PHP_METHOD(dbdo,selectAdd); PHP_METHOD(dbdo,whereAdd); PHP_METHOD(dbdo,limit); PHP_METHOD(dbdo,orderBy); PHP_METHOD(dbdo,groupBy); PHP_METHOD(dbdo,having); PHP_METHOD(dbdo, __call); PHP_METHOD(dbdo, __sleep); */ ZEND_BEGIN_MODULE_GLOBALS(dbdo) void *client; /* needed? */ int debugLevel; /* the debugLevel */ dbdo_config **config; /* the configuration ? dbdo_config */ int config_len; dbdo_table **tables; /* link list of dbdo_table's */ int tables_len; zval **constants; ZEND_END_MODULE_GLOBALS(dbdo) #ifdef ZTS #define DBDO_G(v) TSRMG(dbdo_globals_id, zend_dbdo_globals *, v) #else #define DBDO_G(v) (dbdo_globals.v) #endif #endif /* PHP_DBDO_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */