Re: interbase module patch(fixed)

From: Date: Wed, 11 Oct 2000 13:16:46 +0000
Subject: Re: interbase module patch(fixed)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19590@lists.php.net to get a copy of this message
send this msg to the dev group so one have cvs account 'll update the tree -- moshe. mosdoron@netvision.net.il icq: 1542485 "Max Derkachev" <kot@books.ru> wrote in message news:3A0D4E4A.8A639586@books.ru... > The patch I sent 2 days ago had a bug. > Forgive me my late-night dislexia :) > If you're going to use it, use this one. > > -- > Best regards, > Max A. Derkachev mailto:kot@books.ru > Symbol-Plus Publishing Ltd. > phone: +7 (812) 265-0054, 265-1228, phone/fax: 567-8775 > http://www.Books.Ru -- All Books of Russia > > > ---------------------------------------------------------------------------- ---- > *** php_interbase.h.orig Fri Oct 6 12:02:05 2000 > --- php_interbase.h Sat Nov 11 15:55:05 2000 > *************** > *** 45,48 **** > --- 45,49 ---- > PHP_FUNCTION(ibase_close); > PHP_FUNCTION(ibase_query); > + PHP_FUNCTION(ibase_affected_rows); > PHP_FUNCTION(ibase_fetch_row); > PHP_FUNCTION(ibase_fetch_object); > *************** > *** 83,86 **** > --- 84,88 ---- > long max_links, max_persistent; > long allow_persistent; > + long affected_rows; > int le_blob, le_link, le_plink, le_result, le_query, le_trans; > char *default_user, *default_password; > *************** > *** 157,161 **** > PHP_IBASE_TIMESTAMP = 64, > PHP_IBASE_DATE = 128, > ! PHP_IBASE_TIME = 256 > }; > > --- 159,164 ---- > PHP_IBASE_TIMESTAMP = 64, > PHP_IBASE_DATE = 128, > ! PHP_IBASE_TIME = 256, > ! PHP_IBASE_REC_V = 512 > }; > > *** interbase.c.orig Fri Oct 6 12:01:58 2000 > --- interbase.c Sat Nov 11 15:54:45 2000 > *************** > *** 34,37 **** > --- 34,49 ---- > rfinish could be called repeatedly > emalloc & co. replaced with malloc & co. > + 2000-10-06: Maxim Derkachev <kot@books.ru> > + - added int _php_ibase_affected_rows() > + (used by ibase_affected_rows()). > + 2000-10-10: Maxim Derkachev <kot@books.ru> > + - added php function ibase_affected_rows(), > + it returns affected rows in case of > + INSERT, UPDATE & DELETE queries. > + - added global constant PHP_IBASE_REC_V, > + and it's use in ibase_trans(), so if > + 'READ COMMITED' is a transaction parameter, > + one can also define 'RECORD VERSION' (or 'NO > + RECORD VERSION') transaction parameter. > */ > > *************** > *** 69,72 **** > --- 81,85 ---- > PHP_FE(ibase_close, NULL) > PHP_FE(ibase_query, NULL) > + PHP_FE(ibase_affected_rows, NULL) > PHP_FE(ibase_fetch_row, NULL) > PHP_FE(ibase_fetch_object, NULL) > *************** > *** 509,512 **** > --- 522,526 ---- > REGISTER_LONG_CONSTANT("IBASE_DATE", PHP_IBASE_DATE, CONST_PERSISTENT); > REGISTER_LONG_CONSTANT("IBASE_TIME", PHP_IBASE_TIME, CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("IBASE_REC_V", PHP_IBASE_REC_V, CONST_PERSISTENT); > > return SUCCESS; > *************** > *** 1487,1490 **** > --- 1501,1507 ---- > if (trans_argl & PHP_IBASE_COMMITTED) { > tpb[tpb_len++] = isc_tpb_read_committed; > + if (trans_argl & PHP_IBASE_REC_V) > + tpb[tpb_len++] = isc_tpb_rec_version; > + else tpb[tpb_len++] = isc_tpb_no_rec_version; > } else if (trans_argl & PHP_IBASE_CONSISTENCY) > tpb[tpb_len++] = isc_tpb_consistency; > *************** > *** 1611,1614 **** > --- 1628,1697 ---- > /* }}} */ > > + /* int _php_ibase_affected_rows(ibase_query *ib_query) > + get affected rows */ > + static int _php_ibase_affected_rows ( ibase_query *ib_query ) > + { > + int statement_type; > + int length; > + char type_item[] = {isc_info_sql_stmt_type}; > + char info_records[] = {isc_info_sql_records}; > + char res_buffer[1024]; > + long aff_rows; > + IBLS_FETCH(); > + > + isc_dsql_sql_info( > + IB_STATUS, > + &ib_query->stmt, > + 1, > + type_item, > + sizeof(res_buffer), > + res_buffer); > + > + if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */ > + _php_ibase_error(); > + return -1; > + } > + > + if (res_buffer[0] == isc_info_sql_stmt_type) > + { > + length = isc_vax_integer(&res_buffer[1], 2); > + statement_type = isc_vax_integer(&res_buffer[3], length); > + } > + else { > + return -1; > + } > + > + isc_dsql_sql_info( > + IB_STATUS, > + &ib_query->stmt, > + 1, > + info_records, > + sizeof(res_buffer), > + res_buffer); > + > + if (IB_STATUS[0] && IB_STATUS[1]) { /* error in fetch */ > + _php_ibase_error(); > + return -1; > + } > + > + switch (statement_type) { > + case 2: // insert > + aff_rows = isc_vax_integer(&res_buffer[27], 4); > + break; > + case 3: // update > + aff_rows = isc_vax_integer(&res_buffer[6], 4); > + break; > + case 4: // delete > + aff_rows = isc_vax_integer(&res_buffer[13], 4); > + break; > + default: // n/a > + aff_rows = -1; > + break; > + } > + > + return aff_rows; > + } > + /* }}} */ > + > > /* {{{ proto int ibase_query([int link_identifier,] string query [, int bind_args]) > *************** > *** 1686,1691 **** > --- 1769,1776 ---- > ib_query->stmt = NULL; /* keep stmt when free query */ > _php_ibase_free_query(ib_query); > + IBG(affected_rows) = 0; > ZEND_REGISTER_RESOURCE(return_value, ib_result, IBG(le_result)); > } else { > + IBG(affected_rows) = _php_ibase_affected_rows(ib_query); > _php_ibase_free_query(ib_query); > RETURN_TRUE; > *************** > *** 1693,1697 **** > --- 1778,1793 ---- > } > /* }}} */ > + /* proto int ibase_affected_rows() > + return affected rows of the last insert, update or delete > + */ > + PHP_FUNCTION(ibase_affected_rows) { > + IBLS_FETCH(); > > + if (IBG(affected_rows)) { > + RETURN_LONG(IBG(affected_rows)); > + } > + RETURN_FALSE; > + } > + /* }}} */ > > /* {{{ _php_ibase_var_pval() */ > > ---------------------------------------------------------------------------- ---- > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#19590) next »