cvs: pecl /dbdo dbdo.c php_dbdo.h /dbdo/examples info.php

From: Date: Thu, 07 Apr 2005 15:23:48 +0000
Subject: cvs: pecl /dbdo dbdo.c php_dbdo.h /dbdo/examples info.php
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-2946@lists.php.net to get a copy of this message
alan_k Thu Apr 7 11:23:48 2005 EDT Modified files: /pecl/dbdo dbdo.c php_dbdo.h /pecl/dbdo/examples info.php Log: hopefully allmost all test should now pass

http://cvs.php.net/diff.php/pecl/dbdo/dbdo.c?r1=1.89&r2=1.90&ty=u Index: pecl/dbdo/dbdo.c diff -u pecl/dbdo/dbdo.c:1.89 pecl/dbdo/dbdo.c:1.90 --- pecl/dbdo/dbdo.c:1.89 Thu Apr 7 10:02:51 2005 +++ pecl/dbdo/dbdo.c Thu Apr 7 11:23:47 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dbdo.c,v 1.89 2005/04/07 14:02:51 alan_k Exp $ */ +/* $Id: dbdo.c,v 1.90 2005/04/07 15:23:47 alan_k Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -392,7 +392,7 @@ /* }}} */ -#define hash_add_assoc_long(__arg, __key, __val) hash_add_assoc_long_ex(__arg, __key, strlen(__key), __val) +#define hash_add_assoc_long(__arg, __key, __val) hash_add_assoc_long_ex(__arg, __key, strlen(__key)+1, __val) int hash_add_assoc_long_ex(HashTable *arg, char *key, uint key_len, long n) { @@ -418,15 +418,15 @@ zend_hash_init(&dbdo_class_entry_ce->constants_table, 0, NULL, NULL, 1); /* fetch all returns */ - hash_add_assoc_long(&dbdo_class_entry_ce->constants_table, "OBJECTS", 0); - hash_add_assoc_long(&dbdo_class_entry_ce->constants_table, "KEY_VALUE", 1); - hash_add_assoc_long(&dbdo_class_entry_ce->constants_table, "VALUE", 2); - hash_add_assoc_long(&dbdo_class_entry_ce->constants_table, "SINGLE", 3); + hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "OBJECTS", 0); + hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "KEY_VALUE", 1); + hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "VALUE", 2); + hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "SINGLE", 3); /* update/delete build or use fetchedobject. */ - hash_add_assoc_long(&dbdo_class_entry_ce->constants_table, "BUILD", 1); + hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "BUILD", 1); /* error constants */ - hash_add_assoc_long(&dbdo_class_entry_ce->constants_table, "E_ALL", 3); - hash_add_assoc_long(&dbdo_class_entry_ce->constants_table, "E_FULL", 63); + hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "E_ALL", 3); + hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "E_FULL", 63); @@ -476,7 +476,7 @@ //} */ /* free config */ - + if (DBDO_G(config_len)) { for (i=0;i<DBDO_G(config_len);i++) { @@ -585,7 +585,7 @@ GdaProviderInfo *info; php_info_print_table_start(); php_info_print_table_header(2, "DBDO support", "enabled"); - php_info_print_table_row(2, "CVS id", "$Id: dbdo.c,v 1.89 2005/04/07 14:02:51 alan_k Exp $"); + php_info_print_table_row(2, "CVS id", "$Id: dbdo.c,v 1.90 2005/04/07 15:23:47 alan_k Exp $"); prov_list = gda_config_get_provider_list (); @@ -709,7 +709,9 @@ return ret; } row = (GdaRow *) gda_data_model_get_row (obj->result, obj->row_id); - + if (!row) { + return ret; + } for (column_id = 0; column_id < gda_data_model_get_n_columns (obj->result); column_id++) { zval *value, *ztitle; @@ -734,31 +736,14 @@ /* config */ { dbdo_config *config; - zval *zconfig[5]; array_init(ret); config = dbdo_config_get(obj->table->dsn TSRMLS_CC); - - MAKE_STD_ZVAL(zconfig[0]); - ZVAL_STRING(zconfig[0], config->require_path ? config->require_path : "", 1); - DBDO_ARRAY_ADD(ret,"return_path",zconfig[0]); - - - MAKE_STD_ZVAL(zconfig[1]); - ZVAL_STRING(zconfig[1], config->class_name ? config->class_name : "", 1); - DBDO_ARRAY_ADD(ret,"class_name",zconfig[1]); - - MAKE_STD_ZVAL(zconfig[2]); - ZVAL_STRING(zconfig[2], config->links ? config->links : "", 1); - DBDO_ARRAY_ADD(ret,"links",zconfig[2]); - - MAKE_STD_ZVAL(zconfig[3]); - ZVAL_BOOL(zconfig[3], (int) config->lowercase_columns); - DBDO_ARRAY_ADD(ret,"lowercase_columns",zconfig[3]); - - MAKE_STD_ZVAL(zconfig[4]); - ZVAL_BOOL(zconfig[4], (int) config->quote_identifiers); - DBDO_ARRAY_ADD(ret,"quote_identifiers",zconfig[4]); + add_assoc_string(ret,"require_path",config->require_path ? config->require_path : "", 1); + add_assoc_string(ret,"class_name",config->class_name ? config->class_name : "", 1); + add_assoc_string(ret,"links",config->links ? config->links : "", 1); + add_assoc_long(ret,"quote_identifiers",(int) config->quote_identifiers); + add_assoc_long(ret,"lowercase_columns",(int) config->lowercase_columns); return ret; } @@ -794,7 +779,7 @@ } zconfig = emalloc(sizeof(zval *) * obj->table->keys_len); for (i = 0; i < obj->table->keys_len; i++) { - ALLOC_ZVAL(zconfig[i]); + MAKE_STD_ZVAL(zconfig[i]); ZVAL_STRING(zconfig[i], obj->table->keys[i] , 1); zend_hash_next_index_insert( HASH_OF(ret), (void *) &zconfig[i], @@ -1029,11 +1014,11 @@ DBDO_DEBUG2(16,"calling constructor on object with args %s , %s",dsn, table); - ALLOC_ZVAL(cb_data[0]); + MAKE_STD_ZVAL(cb_data[0]); ZVAL_STRING(cb_data[0], dsn, 1); cb_args[0] = &cb_data[0]; - ALLOC_ZVAL(cb_data[1]); + MAKE_STD_ZVAL(cb_data[1]); ZVAL_STRING(cb_data[1], table, 1); cb_args[1] = &cb_data[1]; @@ -1100,7 +1085,7 @@ row = (GdaRow *) gda_data_model_get_row (obj->table->schema, row_id); value = (GdaValue *) gda_row_get_value (row, column_id); string = gda_value_stringify (value); - ALLOC_ZVAL(zvalue); + MAKE_STD_ZVAL(zvalue); ZVAL_STRING(zvalue, string, 1); g_free(string); zend_hash_next_index_insert(HASH_OF(return_value), &zvalue, sizeof(zval *), NULL); @@ -1124,7 +1109,7 @@ ntitle = estrdup(title); value = (GdaValue *) gda_row_get_value (row, column_id); - ALLOC_ZVAL(zvalue); + MAKE_STD_ZVAL(zvalue); string = gda_value_stringify (value); if (!string) { ZVAL_NULL(zvalue); @@ -1271,7 +1256,7 @@ if (rows != 1) { zend_throw_exception_ex( dbdo_class_entry_exception_ce , 0 TSRMLS_CC, - "DBDO::%s returned %d rows, only one is expected", get_active_function_name(TSRMLS_C), rows); + "DBDO::%s failed to return only 1 row. (%d returned)", get_active_function_name(TSRMLS_C), rows); } dbdo_fetch_into_properties(object TSRMLS_CC); @@ -1475,7 +1460,7 @@ for (r = 0; r < gda_data_model_get_n_rows (obj->result); r++) { zval *zclone; dbdo_object *dclone; - ALLOC_ZVAL(zclone); + MAKE_STD_ZVAL(zclone); zclone->type = IS_OBJECT; zclone->value.obj = dbdo_clone(object TSRMLS_CC); dclone = zend_object_store_get_object(zclone TSRMLS_CC); @@ -1629,15 +1614,15 @@ gtitle = (gchar *) gda_data_model_get_column_title (obj->result, column_id); title = estrdup(gtitle); - - - value = (GdaValue *) gda_row_get_value (row, column_id); - + if (!value) { + efree(title); + return; + } MAKE_STD_ZVAL(znew_value); dbdo_value_to_zval(value, znew_value TSRMLS_CC); - + zend_update_property(Z_OBJCE_P(object), object, title, strlen(title), znew_value TSRMLS_CC); @@ -1661,7 +1646,9 @@ DBDO_DEBUG(16,"FETCH DATA AT ROW %d",obj->row_id); row = (GdaRow *) gda_data_model_get_row (obj->result, obj->row_id); - + if (!row) { + return; + } cols = gda_data_model_get_n_columns (obj->result); for (column_id = 0; column_id < cols; column_id++) { //if (column_id > 4) { @@ -1847,7 +1834,7 @@ ulong h; title = (gchar *) gda_data_model_get_column_title (obj->result, column_id); - ALLOC_ZVAL(ztitle); + MAKE_STD_ZVAL(ztitle); ZVAL_STRING(ztitle, title, 1); value = std_object_handlers.read_property(object, ztitle, 0 TSRMLS_CC); @@ -1930,7 +1917,7 @@ colname = (gchar *) gda_value_get_string ( (GdaValue *) gda_data_model_get_value_at (obj->table->schema, 0, row_id)); - ALLOC_ZVAL(ztitle); + MAKE_STD_ZVAL(ztitle); if (!format_len) { ZVAL_STRING(ztitle, colname, 1); @@ -2014,7 +2001,7 @@ FREE_ZVAL(ztitle); } /* TODO: implement toValue() */ - ALLOC_ZVAL(ztitle); + MAKE_STD_ZVAL(ztitle); ZVAL_STRING(ztitle, colname, 1); /* set it manually.. */ std_object_handlers.write_property(object, ztitle, use TSRMLS_CC); @@ -2465,7 +2452,7 @@ zend_update_property(Z_OBJCE_P(object), object, obj->table->sequenceColumn, strlen(obj->table->sequenceColumn), znew_value TSRMLS_CC); - FREE_ZVAL(znew_value); + zend_objects_store_add_ref(object TSRMLS_CC); } @@ -2650,7 +2637,7 @@ obj->row_id); sql_str = (char *) gda_connection_value_to_sql_string (obj->con,r_gvalue); - DBDO_DEBUG2(1,"ADDING value from result %s,%s", col_name, sql_str); + DBDO_DEBUG2(16,"ADDING value from result %s,%s", col_name, sql_str); if (found_key) { smart_str_appends(&cmd, " AND "); } @@ -3087,9 +3074,9 @@ php_error(E_ERROR, "DBDO::info() no information for unknown key %s", key); RETURN_FALSE; } - MAKE_STD_ZVAL(return_value); + dbdo_info_get(object, return_value, i TSRMLS_CC); - //RETURN_ZVAL(ret ,0,1); + return; } @@ -3353,7 +3340,7 @@ smart_str_appends(&cmd, " = "); /* if we have set the value - use that */ - ALLOC_ZVAL(ztitle); + MAKE_STD_ZVAL(ztitle); ZVAL_STRING(ztitle, obj->table->sequenceColumn, 1); if (std_object_handlers.has_property(object, ztitle, 0 TSRMLS_CC)) { @@ -3460,7 +3447,7 @@ g_free(test); - ALLOC_ZVAL(ztitle); + MAKE_STD_ZVAL(ztitle); ZVAL_STRING(ztitle, col, 1); /* set it manually.. */ std_object_handlers.write_property(object, ztitle, value TSRMLS_CC); @@ -3567,7 +3554,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "To many arguments to '%s'",function); } zval *member, *ret; - ALLOC_ZVAL(member); + MAKE_STD_ZVAL(member); ZVAL_STRING(member, function+3, 0); /* we have no idea what type (3rd arg means but we are sticking 1 in there */ @@ -3607,7 +3594,7 @@ RETURN_FALSE; } g_free(test); - ALLOC_ZVAL(ztitle); + MAKE_STD_ZVAL(ztitle); ZVAL_STRING(ztitle, function+3, 1); /* set it manually.. */ http://cvs.php.net/diff.php/pecl/dbdo/php_dbdo.h?r1=1.36&r2=1.37&ty=u Index: pecl/dbdo/php_dbdo.h diff -u pecl/dbdo/php_dbdo.h:1.36 pecl/dbdo/php_dbdo.h:1.37 --- pecl/dbdo/php_dbdo.h:1.36 Thu Apr 7 08:49:08 2005 +++ pecl/dbdo/php_dbdo.h Thu Apr 7 11:23:47 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_dbdo.h,v 1.36 2005/04/07 12:49:08 alan_k Exp $ */ +/* $Id: php_dbdo.h,v 1.37 2005/04/07 15:23:47 alan_k Exp $ */ #ifndef PHP_DBDO_H #define PHP_DBDO_H @@ -40,7 +40,7 @@ #include "Zend/zend_execute.h" #include "Zend/zend_exceptions.h" -#define DBDO_FULL_DEBUG 1 +#define DBDO_FULL_DEBUG 0 #if DBDO_FULL_DEBUG http://cvs.php.net/diff.php/pecl/dbdo/examples/info.php?r1=1.7&r2=1.8&ty=u Index: pecl/dbdo/examples/info.php diff -u pecl/dbdo/examples/info.php:1.7 pecl/dbdo/examples/info.php:1.8 --- pecl/dbdo/examples/info.php:1.7 Tue Mar 22 07:55:08 2005 +++ pecl/dbdo/examples/info.php Thu Apr 7 11:23:47 2005 @@ -6,6 +6,10 @@ // set up source test to use database test.. DBDO::config('test','provider','MySQL'); DBDO::config('test','cnc','DATABASE=test;USER=alan'); +DBDO::config('test','require_path','DBDO/%s.php'); +DBDO::config('test','class_name','DBDO_%s'); +DBDO::config('test','links','todo'); + DBDO::debugLevel(DBDO::E_ALL); $x = new DBDO('test', 'test'); @@ -16,7 +20,10 @@ $x = new DBDO('test', 'test'); -$x->get(3); +try { + $x->get(3); +} catch (Exception $e) { +} $x->firstname = "the dog"; print_r($x->info());
« previous php.pecl.cvs (#2946) next »