[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-04-25 Thread Frank M. Kromann

fmk Wed Apr 25 12:45:14 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  Remove c++ comment
  Move errormessage when FBExec is not running. This error should not show if we 
connect through a port number.
  
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.13 php4/ext/fbsql/php_fbsql.c:1.14
--- php4/ext/fbsql/php_fbsql.c:1.13 Wed Apr 25 11:01:22 2001
+++ php4/ext/fbsql/php_fbsql.c  Wed Apr 25 12:45:13 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.13 2001/04/25 18:01:22 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.14 2001/04/25 19:45:13 fmk Exp $ */
 
 /* TODO:
  *
@@ -521,12 +521,6 @@
{
FBCExecHandler* execHandler = fbcehHandlerForHost(hostName,128);
list_entry le;
-   if (execHandler == NULL)
-   {
-   php_error(E_WARNING,"Cannot connect to host '%s'",hostName);
-   php_error(E_WARNING,fbcehClassErrorMessage());
-// return NULL;
-   }
result = malloc(sizeof(PHPFBLink));
result->retainCount = 1;
result->persistant  = persistant;
@@ -1115,7 +1109,15 @@
phpLink = phpfbGetLink(FB_SQL_G(linkIndex));
}
if (phpLink == NULL) RETURN_FALSE;
-/* printf("Select db at link %s@%s\n",phpLink->hostName,phpLink->userName); */
+   if (phpLink->execHandler == NULL)
+   {
+   int port = atoi(name);
+   if (port == 0 || port > 64535) {
+   php_error(E_WARNING,"Cannot connect to FBExec for database 
+'%s'",name);
+   php_error(E_WARNING,fbcehClassErrorMessage());
+   RETURN_FALSE;
+   }
+   }
 
database = phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU,name,phpLink);
if (database == NULL) RETURN_FALSE;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-04-25 Thread Andi Gutmans

Frank,

Don't forget not to use C++ comments.
Thanks,

Andi

At 06:01 PM 4/25/2001 +, Frank M. Kromann wrote:
>fmk Wed Apr 25 11:01:23 2001 EDT
>
>   Modified files:
> /php4/ext/fbsql php_fbsql.c
>   Log:
>   make fbsql_field_flags return a value
>
>Index: php4/ext/fbsql/php_fbsql.c
>diff -u php4/ext/fbsql/php_fbsql.c:1.12 php4/ext/fbsql/php_fbsql.c:1.13
>--- php4/ext/fbsql/php_fbsql.c:1.12 Tue Apr 17 10:39:43 2001
>+++ php4/ext/fbsql/php_fbsql.c  Wed Apr 25 11:01:22 2001
>@@ -16,7 +16,7 @@
> +--+
>   */
>
>-/* $Id: php_fbsql.c,v 1.12 2001/04/17 17:39:43 fmk Exp $ */
>+/* $Id: php_fbsql.c,v 1.13 2001/04/25 18:01:22 fmk Exp $ */
>
>  /* TODO:
>   *
>@@ -525,7 +525,7 @@
> {
> php_error(E_WARNING,"Cannot connect to host 
> '%s'",hostName);
> php_error(E_WARNING,fbcehClassErrorMessage());
>-   return NULL;
>+// return NULL;
> }
> result = malloc(sizeof(PHPFBLink));
> result->retainCount = 1;
>@@ -2780,17 +2780,16 @@
> add_property_string(return_value, 
> "name", 
> (char*)fbccmdLabelName(fbcmdColumnMetaDataAtIndex(result->metaData, 
> column)),1);
> add_property_string(return_value, 
> "table", 
> (char*)fbccmdTableName(fbcmdColumnMetaDataAtIndex(result->metaData,column)),1);
> add_property_long(return_value,   "max_length", 
> fbcdmdLength(fbccmdDatatype(fbcmdColumnMetaDataAtIndex(result->metaData,column;
>-   add_property_string(return_value, 
>"type",   (char*)fbcdmdDatatypeString 
>(fbcmdDatatypeMetaDataAtIndex(result->metaData, column)),1);
>+   add_property_string(return_value, 
>"type", 
>(char*)fbcdmdDatatypeString(fbcmdDatatypeMetaDataAtIndex(result->metaData, 
>column)),1);
>+   add_property_long(return_value,   "not_null", 
>!fbccmdIsNullable(fbcmdColumnMetaDataAtIndex(result->metaData, column)));
>  /* Remember to add the rest */
>-/* add_property_long(return_value, 
>"not_null",IS_NOT_NULL(mysql_field->flags)?1:0); */
>-/* add_property_long(return_value, 
>"primary_key",IS_PRI_KEY(mysql_field->flags)?1:0); */
>-/* add_property_long(return_value, 
>"multiple_key",(mysql_field->flags&MULTIPLE_KEY_FLAG?1:0)); */
>-/* add_property_long(return_value, 
>"unique_key",(mysql_field->flags&UNIQUE_KEY_FLAG?1:0)); */
>-/* add_property_long(return_value, 
>"numeric",IS_NUM(mysql_field->type)?1:0); */
>-/* add_property_long(return_value, 
>"blob",IS_BLOB(mysql_field->flags)?1:0); */
>-/* add_property_string(return_value, 
>"type",php_mysql_get_field_name(mysql_field->type), 1); */
>-/* add_property_long(return_value, 
>"unsigned",(mysql_field->flags&UNSIGNED_FLAG?1:0)); */
>-/* add_property_long(return_value, 
>"zerofill",(mysql_field->flags&ZEROFILL_FLAG?1:0)); */
>+/* add_property_long(return_value, 
>"primary_key",IS_PRI_KEY(fbsql_field->flags)?1:0); */
>+/* add_property_long(return_value, 
>"multiple_key",(fbsql_field->flags&MULTIPLE_KEY_FLAG?1:0)); */
>+/* add_property_long(return_value, 
>"unique_key",(fbsql_field->flags&UNIQUE_KEY_FLAG?1:0)); */
>+/* add_property_long(return_value, 
>"numeric",IS_NUM(fbsql_field->type)?1:0); */
>+/* add_property_long(return_value, 
>"blob",IS_BLOB(fbsql_field->flags)?1:0); */
>+/* add_property_long(return_value, 
>"unsigned",(fbsql_field->flags&UNSIGNED_FLAG?1:0)); */
>+/* add_property_long(return_value, 
>"zerofill",(fbsql_field->flags&ZEROFILL_FLAG?1:0)); */
>  }
>  /* }}} */
>
>@@ -2843,7 +2842,7 @@
>  /* }}} */
>
>
>-/* {{{ proto string mysql_field_name(int result, int field_index)
>+/* {{{ proto string fbsql_field_name(int result, int field_index)
> */
>  PHP_FUNCTION(fbsql_field_name)
>  {
>@@ -3069,7 +3068,7 @@
>  /* }}} */
>
>
>-/* {{{ proto string fbsql_field_flags(int result, int field_index)
>+/* {{{ proto string string fbsql_field_flags(int result[, int field_index])
> */
>  PHP_FUNCTION(fbsql_field_flags)
>  {
>@@ -3078,6 +3077,8 @@
> int resultIndex;
> PHPFBResult* result;
> int column;
>+   char buf[512];
>+   int  len;
> FBSQLLS_FETCH();
>
> resultIndex = FB_SQL_G(resultIndex);
>@@ -3109,12 +3110,51 @@
> RETURN_FALSE;
> }
> }
>-   if (array_init(return_value)==FAILURE)
>-   {
>-   RETURN_FALSE;
>+   strcpy(buf, "");
>+   if (!fbccmdIsNullable(fbcmdColumnMetaDataAtIndex(result->metaData, 
>column))) {
>+   strcat(buf, "not_null ");
> }
>-   /* We should create the result -- currently empty */
>-
>+#if 0
>+   if (IS_PRI_KEY(fbsql_field->flags)) {
>+   strcat(buf, "primary_key ");
>+   }
>+   if (fbsql_field->flags&UNIQUE_KEY_FLAG) {
>+   strcat(buf, "unique_key ");
>+

[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-04-25 Thread Frank M. Kromann

fmk Wed Apr 25 11:01:23 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  make fbsql_field_flags return a value
  
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.12 php4/ext/fbsql/php_fbsql.c:1.13
--- php4/ext/fbsql/php_fbsql.c:1.12 Tue Apr 17 10:39:43 2001
+++ php4/ext/fbsql/php_fbsql.c  Wed Apr 25 11:01:22 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.12 2001/04/17 17:39:43 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.13 2001/04/25 18:01:22 fmk Exp $ */
 
 /* TODO:
  *
@@ -525,7 +525,7 @@
{
php_error(E_WARNING,"Cannot connect to host '%s'",hostName);
php_error(E_WARNING,fbcehClassErrorMessage());
-   return NULL;
+// return NULL;
}
result = malloc(sizeof(PHPFBLink));
result->retainCount = 1;
@@ -2780,17 +2780,16 @@
add_property_string(return_value, "name",   
(char*)fbccmdLabelName(fbcmdColumnMetaDataAtIndex(result->metaData, column)),1);
add_property_string(return_value, "table",  
(char*)fbccmdTableName(fbcmdColumnMetaDataAtIndex(result->metaData,column)),1);
add_property_long(return_value,   "max_length", 
fbcdmdLength(fbccmdDatatype(fbcmdColumnMetaDataAtIndex(result->metaData,column;
-   add_property_string(return_value, "type",   (char*)fbcdmdDatatypeString 
(fbcmdDatatypeMetaDataAtIndex(result->metaData, column)),1);
+   add_property_string(return_value, "type",   
+(char*)fbcdmdDatatypeString(fbcmdDatatypeMetaDataAtIndex(result->metaData, 
+column)),1);
+   add_property_long(return_value,   "not_null",   
+!fbccmdIsNullable(fbcmdColumnMetaDataAtIndex(result->metaData, column)));
 /* Remember to add the rest */
-/* add_property_long(return_value, 
"not_null",IS_NOT_NULL(mysql_field->flags)?1:0); */
-/* add_property_long(return_value, 
"primary_key",IS_PRI_KEY(mysql_field->flags)?1:0); */
-/* add_property_long(return_value, 
"multiple_key",(mysql_field->flags&MULTIPLE_KEY_FLAG?1:0)); */
-/* add_property_long(return_value, 
"unique_key",(mysql_field->flags&UNIQUE_KEY_FLAG?1:0)); */
-/* add_property_long(return_value, "numeric",IS_NUM(mysql_field->type)?1:0); */
-/* add_property_long(return_value, "blob",IS_BLOB(mysql_field->flags)?1:0); */
-/* add_property_string(return_value, 
"type",php_mysql_get_field_name(mysql_field->type), 1); */
-/* add_property_long(return_value, 
"unsigned",(mysql_field->flags&UNSIGNED_FLAG?1:0)); */
-/* add_property_long(return_value, 
"zerofill",(mysql_field->flags&ZEROFILL_FLAG?1:0)); */
+/* add_property_long(return_value, 
+"primary_key",IS_PRI_KEY(fbsql_field->flags)?1:0); */
+/* add_property_long(return_value, 
+"multiple_key",(fbsql_field->flags&MULTIPLE_KEY_FLAG?1:0)); */
+/* add_property_long(return_value, 
+"unique_key",(fbsql_field->flags&UNIQUE_KEY_FLAG?1:0)); */
+/* add_property_long(return_value, "numeric",IS_NUM(fbsql_field->type)?1:0); */
+/* add_property_long(return_value, "blob",IS_BLOB(fbsql_field->flags)?1:0); */
+/* add_property_long(return_value, 
+"unsigned",(fbsql_field->flags&UNSIGNED_FLAG?1:0)); */
+/* add_property_long(return_value, 
+"zerofill",(fbsql_field->flags&ZEROFILL_FLAG?1:0)); */
 }
 /* }}} */
 
@@ -2843,7 +2842,7 @@
 /* }}} */
 
 
-/* {{{ proto string mysql_field_name(int result, int field_index)
+/* {{{ proto string fbsql_field_name(int result, int field_index)
*/
 PHP_FUNCTION(fbsql_field_name)
 {
@@ -3069,7 +3068,7 @@
 /* }}} */
 
 
-/* {{{ proto string fbsql_field_flags(int result, int field_index)
+/* {{{ proto string string fbsql_field_flags(int result[, int field_index])
*/
 PHP_FUNCTION(fbsql_field_flags)
 {
@@ -3078,6 +3077,8 @@
int resultIndex;
PHPFBResult* result;
int column;
+   char buf[512];
+   int  len;
FBSQLLS_FETCH();
 
resultIndex = FB_SQL_G(resultIndex);
@@ -3109,12 +3110,51 @@
RETURN_FALSE;
}
}
-   if (array_init(return_value)==FAILURE)
-   {
-   RETURN_FALSE;
+   strcpy(buf, "");
+   if (!fbccmdIsNullable(fbcmdColumnMetaDataAtIndex(result->metaData, column))) {
+   strcat(buf, "not_null ");
}
-   /* We should create the result -- currently empty */
-
+#if 0
+   if (IS_PRI_KEY(fbsql_field->flags)) {
+   strcat(buf, "primary_key ");
+   }
+   if (fbsql_field->flags&UNIQUE_KEY_FLAG) {
+   strcat(buf, "unique_key ");
+   }
+   if (fbsql_field->flags&MULTIPLE_KEY_FLAG) {
+   strcat(buf, "multiple_key ");
+   }
+   if (IS_BLOB(fbsql_field->flags)) {
+   strcat(buf, "blob ");
+   }
+   if (fbsql_field->flags&UNSIGNED_FLAG) 

[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c php_fbsql.h

2001-04-17 Thread Frank M. Kromann

fmk Tue Apr 17 10:39:43 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.h php_fbsql.c 
  Log:
  Adding fbsql_fetch_assoc() functon
  
Index: php4/ext/fbsql/php_fbsql.h
diff -u php4/ext/fbsql/php_fbsql.h:1.2 php4/ext/fbsql/php_fbsql.h:1.3
--- php4/ext/fbsql/php_fbsql.h:1.2  Wed Apr  4 13:10:14 2001
+++ php4/ext/fbsql/php_fbsql.h  Tue Apr 17 10:39:43 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.h,v 1.2 2001/04/04 20:10:14 fmk Exp $ */
+/* $Id: php_fbsql.h,v 1.3 2001/04/17 17:39:43 fmk Exp $ */
 
 #define HAVE_FBSQL 1
 
@@ -67,6 +67,7 @@
 PHP_FUNCTION(fbsql_num_fields);
 PHP_FUNCTION(fbsql_fetch_row);
 PHP_FUNCTION(fbsql_fetch_array);
+PHP_FUNCTION(fbsql_fetch_assoc);
 PHP_FUNCTION(fbsql_fetch_object);
 PHP_FUNCTION(fbsql_data_seek);
 PHP_FUNCTION(fbsql_fetch_lengths);
@@ -87,6 +88,8 @@
 PHP_FUNCTION(fbsql_username);
 PHP_FUNCTION(fbsql_password);
 PHP_FUNCTION(fbsql_warnings);
+
+static void php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type);
 
 ZEND_BEGIN_MODULE_GLOBALS(fbsql)
long allowPersistent;
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.11 php4/ext/fbsql/php_fbsql.c:1.12
--- php4/ext/fbsql/php_fbsql.c:1.11 Mon Apr 16 09:27:11 2001
+++ php4/ext/fbsql/php_fbsql.c  Tue Apr 17 10:39:43 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.11 2001/04/16 16:27:11 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.12 2001/04/17 17:39:43 fmk Exp $ */
 
 /* TODO:
  *
@@ -201,6 +201,7 @@
PHP_FE(fbsql_num_fields,NULL)
PHP_FE(fbsql_fetch_row, NULL)
PHP_FE(fbsql_fetch_array,   NULL)
+   PHP_FE(fbsql_fetch_assoc,   NULL)
PHP_FE(fbsql_fetch_object,  NULL)
PHP_FE(fbsql_data_seek, NULL)
PHP_FE(fbsql_fetch_lengths, NULL)
@@ -2523,11 +2524,29 @@
 /* }}} */
 
 
-/* {{{ proto object fbsql_fetch_object(int result [, int result_typ])
+/* {{{ proto array fbsql_fetch_row(int result)
+   */
+PHP_FUNCTION(fbsql_fetch_row)
+{
+   php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_NUM);
+}
+/* }}} */
+
+
+/* {{{ proto object fbsql_fetch_assoc(int result)
*/
+PHP_FUNCTION(fbsql_fetch_assoc)
+{
+   php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_ASSOC);
+}
+/* }}} */
+
+
+/* {{{ proto object fbsql_fetch_object(int result [, int result_type])
+   */
 PHP_FUNCTION(fbsql_fetch_object)
 {
-   PHP_FN(fbsql_fetch_array)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+   php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_ASSOC);
if (return_value->type==IS_ARRAY)
{
return_value->type=IS_OBJECT;
@@ -2538,72 +2557,15 @@
 /* }}} */
 
 
-/* {{{ proto array fbsql_fetch_row(int result)
-   */
-PHP_FUNCTION(fbsql_fetch_row)
+/* {{{ proto array fbsql_fetch_array(int result [, int result_type])
+   Fetch a result row as an array (associative, numeric or both)*/
+PHP_FUNCTION(fbsql_fetch_array)
 {
-   int   argc= ARG_COUNT(ht);
-   zval**argv[2];
-   int i;
-   int resultIndex;
-   PHPFBResult*   result;
-   int rowIndex ;
-   void**  row;
-   FBSQLLS_FETCH();
-
-   resultIndex = FB_SQL_G(resultIndex);
-
-   if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(argc,&argv[0])==FAILURE) RETURN_FALSE;
-
-   if (argc >= 1) {
-   convert_to_long_ex(argv[0]);
-   resultIndex = (*argv[0])->value.lval;
-   }
-   result = phpfbGetResult(resultIndex);
-   if (result == NULL) RETURN_FALSE;
-   
-   rowIndex = result->rowIndex;
-
-   if (result->fetchHandle == NULL) {
-   RETURN_FALSE;
-   }
-   if (result->rowCount == 0) {
-   RETURN_FALSE;
-   }
-   if (result->rowCount == 0x7fff) {
-   if (!phpfbFetchRow(result,rowIndex)) {
-   RETURN_FALSE;
-   }
-   }
-   if (!(row = fbcrhRowAtIndex(result->rowHandler,rowIndex))) {
-   RETURN_FALSE;
-   }
-   if (array_init(return_value)==FAILURE) {
-   RETURN_FALSE;
-   }
-   result->row = row;
-   for (i=0; i < result->columnCount; i++) {
-   char*value;
-   unsigned int length;
-   if (row[i]) {
-   phpfbColumnAsString(result,i,row[i],&length,&value);
-   add_index_stringl(return_value,i,value,length,0);
-   }
-   else {
-   add_index_unset(return_value,i);
-   }
-   }
-   result->rowIndex= rowIndex+1;
-   result->columnIndex = 0;
-   FB_SQL_G(resultIndex) = resultIndex;
+   php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_

[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-04-16 Thread Frank M. Kromann

fmk Mon Apr 16 09:27:12 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  Fixing memory leek on CancelFetch.
  
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.10 php4/ext/fbsql/php_fbsql.c:1.11
--- php4/ext/fbsql/php_fbsql.c:1.10 Tue Apr 10 11:44:51 2001
+++ php4/ext/fbsql/php_fbsql.c  Mon Apr 16 09:27:11 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.10 2001/04/10 18:44:51 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.11 2001/04/16 16:27:11 fmk Exp $ */
 
 /* TODO:
  *
@@ -269,7 +269,10 @@
 
if (result->retainCount == 0)
{
-   if (result->fetchHandle) 
fbcdcCancelFetch(result->connection,result->fetchHandle);
+   if (result->fetchHandle) {
+   FBCMetaData *md = 
+fbcdcCancelFetch(result->connection,result->fetchHandle);
+   fbcmdRelease(md);
+   }
if (result->rowHandler)  fbcrhRelease(result->rowHandler);
if (result->ResultmetaData)
fbcmdRelease(result->ResultmetaData);
 /* if (result->metaData)fbcmdRelease(result->metaData);  */
@@ -717,7 +720,7 @@
 {
PHPFBDatabase* result = NULL;
list_entry *lep;
-   unsigned i;
+   unsigned i, port;
char name[1024];
FBSQLLS_FETCH();
 
@@ -742,8 +745,14 @@
else
{
list_entry le;
-   FBCDatabaseConnection* c = 
fbcdcConnectToDatabase(databaseName,link->hostName,FB_SQL_G(databasePassword));
+   FBCDatabaseConnection* c;
FBCMetaData*   md;
+
+   port = atoi(databaseName);
+   if (port>0 && port<65535)
+   c = fbcdcConnectToDatabaseUsingPort(link->hostName, 
+port,FB_SQL_G(databasePassword));
+   else
+   c = 
+fbcdcConnectToDatabase(databaseName,link->hostName,FB_SQL_G(databasePassword));
if (c == NULL)
{
php_error(E_WARNING, fbcdcClassErrorMessage());
@@ -942,68 +951,85 @@
 /* }}} */
 
 
-/* {{{ proto string fbsql_hostname([string host_name])
+/* {{{ proto string fbsql_hostname(int link_identifier [, string host_name])
*/
 PHP_FUNCTION(fbsql_hostname)
 {
int argc = ARG_COUNT(ht);
-   zval**argv[1];
+   zval**argv[2];
+   PHPFBLink* phpLink = NULL;
FBSQLLS_FETCH();
 
-   if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(argc, &argv[0])==FAILURE) RETURN_FALSE;
+   if ((argc < 1) || (argc > 2)) WRONG_PARAM_COUNT;
+   if (zend_get_parameters_ex(argc,&argv[0],&argv[1])==FAILURE) RETURN_FALSE;
+
+   convert_to_long_ex(argv[0]);
+   phpLink = phpfbGetLink((*argv[0])->value.lval);
+   if (phpLink == NULL) RETURN_FALSE;
 
-   phpfbestrdup(FB_SQL_G(hostName), &return_value->value.str.len, 
&return_value->value.str.val);
+   phpfbestrdup(phpLink->hostName, &return_value->value.str.len, 
+&return_value->value.str.val);
return_value->type = IS_STRING;
-   if (argc >= 1)
+   if (argc == 2)
{
-   convert_to_string_ex(argv[0]);
-   free(FB_SQL_G(hostName));
-   FB_SQL_G(hostName) = strdup((*argv[0])->value.str.val);
+   convert_to_string_ex(argv[1]);
+   if (phpLink->hostName) free(phpLink->hostName);
+   phpLink->hostName = strdup((*argv[1])->value.str.val);
}
 }
 /* }}} */
 
 
-/* {{{ proto string fbsql_database([string database])
+/* {{{ proto string fbsql_database(int link_identifier [, string database])
*/
 PHP_FUNCTION(fbsql_database)
 {
int  argc = ARG_COUNT(ht);
-   zval**argv[1];
+   zval**argv[2];
+   PHPFBLink* phpLink = NULL;
FBSQLLS_FETCH();
 
-   if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(argc, &argv[0])==FAILURE) RETURN_FALSE;
+   if ((argc < 1) || (argc > 2)) WRONG_PARAM_COUNT;
+   if (zend_get_parameters_ex(argc,&argv[0],&argv[1])==FAILURE) RETURN_FALSE;
+
+   convert_to_long_ex(argv[0]);
+   phpLink = phpfbGetLink((*argv[0])->value.lval);
+   if (phpLink == NULL) RETURN_FALSE;
 
-   phpfbestrdup(FB_SQL_G(databaseName), &return_value->value.str.len, 
&return_value->value.str.val);
+   phpfbestrdup(phpLink->currentDatabase->databaseName, 
+&return_value->value.str.len, &return_value->value.str.val);
return_value->type = IS_STRING;
-   if (argc >= 1)
+   if (argc == 2)
{
-   convert_to_string_ex(argv[0]);
-   free(FB_SQL_G(databaseName));
-   FB_SQL_G(databaseName) = strdup((*argv[0])->value.str.val);
+   convert_to_str

[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-04-10 Thread Frank M. Kromann

fmk Tue Apr 10 11:44:51 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  Fixing database password to actually work
  
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.9 php4/ext/fbsql/php_fbsql.c:1.10
--- php4/ext/fbsql/php_fbsql.c:1.9  Wed Apr  4 13:10:14 2001
+++ php4/ext/fbsql/php_fbsql.c  Tue Apr 10 11:44:51 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.9 2001/04/04 20:10:14 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.10 2001/04/10 18:44:51 fmk Exp $ */
 
 /* TODO:
  *
@@ -408,10 +408,6 @@
name[sizeof(name)-1] = 0;
fbsql_globals->hostName = strdup(name);
}
-/* fbsql_globals->userName = strdup(fbsql_globals->userName); */
-/* fbsql_globals->userPassword = strdup(fbsql_globals->userPassword); 
*/
-/* fbsql_globals->databaseName = strdup(fbsql_globals->databaseName); 
*/
-/* fbsql_globals->databasePassword = strdup(fbsql_globals->databasePassword); */
 
fbsql_globals->persistantCount  = 0;
fbsql_globals->linkCount= 0;
@@ -713,13 +709,9 @@
 }
 /* }}} */
 
-
-/* {{{ proto int fbsql_select_db(string database_name [, int link_identifier]
-   */
 PHPFBDatabase* phpfbSelectDB 
 (  INTERNAL_FUNCTION_PARAMETERS,
char*databaseName,
-   char*databasePassword,
PHPFBLink*   link
 )
 {
@@ -750,7 +742,7 @@
else
{
list_entry le;
-   FBCDatabaseConnection* c = 
fbcdcConnectToDatabase(databaseName,link->hostName,databasePassword);
+   FBCDatabaseConnection* c = 
+fbcdcConnectToDatabase(databaseName,link->hostName,FB_SQL_G(databasePassword));
FBCMetaData*   md;
if (c == NULL)
{
@@ -800,7 +792,7 @@
result->index= zend_list_insert((PHPFBDatabase*)(le.ptr), 
le_dba);
result->link = phpfbRetainLink(link);
result->databaseName = strdup(databaseName);
-   result->databasePassword = strdup(databasePassword);
+   result->databasePassword = strdup(FB_SQL_G(databasePassword));
result->connection   = c;
result->errorNo  = 0;
result->errorText= NULL;
@@ -1010,7 +1002,7 @@
if (argc >= 1)
{
convert_to_string_ex(argv[0]);
-   free(FB_SQL_G(hostName));
+   free(FB_SQL_G(databasePassword));
FB_SQL_G(databasePassword) = strdup((*argv[0])->value.str.val); 
}
 }
@@ -1098,7 +1090,7 @@
if (phpLink == NULL) RETURN_FALSE;
 /* printf("Select db at link %s@%s\n",phpLink->hostName,phpLink->userName); */
 
-   database = phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU,name,"",phpLink);
+   database = phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU,name,phpLink);
if (database == NULL) RETURN_FALSE;
 
phpLink->currentDatabase  = database;
@@ -1147,7 +1139,7 @@
link = (*argv[3])->value.lval;
}
if ((phpLink = phpfbGetLink(link))==NULL) RETURN_FALSE;
-   if ((phpDatabase = 
phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU,databaseName,"",phpLink)) == NULL) 
RETURN_FALSE;
+   if ((phpDatabase = 
+phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU,databaseName,phpLink)) == NULL) 
+RETURN_FALSE;
{
char buffer[1024];
sprintf(buffer,"SET AUTHORIZATION %s;",userName);
@@ -1348,7 +1340,7 @@
if (phpLink == NULL) RETURN_FALSE;
}
 
-   phpDatabase = phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
databaseName,"",phpLink);
+   phpDatabase = phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
+databaseName,phpLink);
if (phpDatabase == NULL) RETURN_FALSE;
 
 /* printf("Stop db %x\n",phpDatabase->connection); */
@@ -1698,7 +1690,7 @@
}
if (phpLink == NULL) RETURN_FALSE;
 /* printf("Query db at link %s@%s\n",phpLink->hostName,phpLink->userName); */
-   phpDatabase = phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
databaseName,"",phpLink);
+   phpDatabase = phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
+databaseName,phpLink);
if (phpDatabase == NULL) RETURN_FALSE;
  
phpResult = phpfbQuery(INTERNAL_FUNCTION_PARAM_PASSTHRU,sql,phpDatabase);
@@ -1818,11 +1810,11 @@
   
if (databaseName == NULL)
{
-   phpLink->currentDatabase = 
phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU, FB_SQL_G(databaseName),"",phpLink);
+   phpLink->currentDatabase = 
+phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU, FB_SQL_G(databaseName),phpLink);
}
else 
{
-   phpLink->currentDatabase = 
phpfbSelectDB(INTERNAL_FUNCTION_PARAM_PASSTHRU, datab

[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c php_fbsql.h

2001-04-04 Thread Frank M. Kromann

fmk Wed Apr  4 13:10:14 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.h php_fbsql.c 
  Log:
  Adding empty RSHUTDOWN function.
  
Index: php4/ext/fbsql/php_fbsql.h
diff -u php4/ext/fbsql/php_fbsql.h:1.1 php4/ext/fbsql/php_fbsql.h:1.2
--- php4/ext/fbsql/php_fbsql.h:1.1  Tue Mar 13 12:58:47 2001
+++ php4/ext/fbsql/php_fbsql.h  Wed Apr  4 13:10:14 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.h,v 1.1 2001/03/13 20:58:47 fmk Exp $ */
+/* $Id: php_fbsql.h,v 1.2 2001/04/04 20:10:14 fmk Exp $ */
 
 #define HAVE_FBSQL 1
 
@@ -39,8 +39,9 @@
 #include 
 
 extern PHP_MINIT_FUNCTION(fbsql);
-extern PHP_RINIT_FUNCTION(fbsql);
 extern PHP_MSHUTDOWN_FUNCTION(fbsql);
+extern PHP_RINIT_FUNCTION(fbsql);
+extern PHP_RSHUTDOWN_FUNCTION(fbsql);
 PHP_MINFO_FUNCTION(fbsql);
 PHP_FUNCTION(fbsql_connect);
 PHP_FUNCTION(fbsql_pconnect);
@@ -106,7 +107,7 @@
long databaseCount;
long resultCount;
 
-   int linkIndex;
+   unsigned int linkIndex;
int databaseIndex;
int resultIndex;
 ZEND_END_MODULE_GLOBALS(fbsql)
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.8 php4/ext/fbsql/php_fbsql.c:1.9
--- php4/ext/fbsql/php_fbsql.c:1.8  Tue Apr  3 11:09:02 2001
+++ php4/ext/fbsql/php_fbsql.c  Wed Apr  4 13:10:14 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.8 2001/04/03 18:09:02 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.9 2001/04/04 20:10:14 fmk Exp $ */
 
 /* TODO:
  *
@@ -237,7 +237,7 @@
PHP_MINIT(fbsql),
PHP_MSHUTDOWN(fbsql),
PHP_RINIT(fbsql),
-   NULL,
+   PHP_RSHUTDOWN(fbsql),
PHP_MINFO(fbsql),
STANDARD_MODULE_PROPERTIES
 };
@@ -361,12 +361,13 @@
 
 void phpfbReleaseLink (PHPFBLink* link)
 {
+   FBSQLLS_FETCH();
if (link)
{
link->retainCount--;
if (link->retainCount == 0)
{
-/* if (link->index == FB_SQL_G(linkIndex) FB_SQL_G(linkIndex = 0; 
*/
+   if (link->index == FB_SQL_G(linkIndex)) FB_SQL_G(linkIndex)--;
free(link->hostName);
free(link->userName);
free(link->userPassword);
@@ -446,6 +447,11 @@
 }
 
 PHP_RINIT_FUNCTION(fbsql)
+{
+   return SUCCESS;
+}
+
+PHP_RSHUTDOWN_FUNCTION(fbsql)
 {
return SUCCESS;
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-04-03 Thread Frank M. Kromann

fmk Tue Apr  3 11:09:02 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  Fixing crash when listing databsaes
  Fixing rowcount to woirk when the result contains an array og data.
  
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.7 php4/ext/fbsql/php_fbsql.c:1.8
--- php4/ext/fbsql/php_fbsql.c:1.7  Thu Mar 22 16:58:59 2001
+++ php4/ext/fbsql/php_fbsql.c  Tue Apr  3 11:09:02 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.7 2001/03/23 00:58:59 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.8 2001/04/03 18:09:02 fmk Exp $ */
 
 /* TODO:
  *
@@ -1745,6 +1745,7 @@
phpResult->connection  = NULL;
phpResult->fetchHandle = NULL;
phpResult->rowHandler  = NULL;
+   phpResult->ResultmetaData= NULL;
phpResult->metaData= NULL;
phpResult->batchSize   = FB_SQL_G(batchSize);
phpResult->columnCount = 1;
@@ -1763,11 +1764,11 @@
phpLink->results = realloc(phpLink->results,sizeof(PHPFBResult*)* 
phpLink->resultCount);
for (j=i; j < phpLink->resultCount ; j++)phpLink->results[j] = NULL;
}
-   phpLink->results[i] = phpResult;
+   phpLink->results[i] = phpResult;
return_value->value.lval = phpResult->index;
-   return_value->type   = IS_LONG;
-   FB_SQL_G(resultIndex)  = phpResult->index;
-   FB_SQL_G(linkIndex)= phpLink->index;
+   return_value->type = IS_LONG;
+   FB_SQL_G(resultIndex) = phpResult->index;
+   FB_SQL_G(linkIndex) = phpLink->index;
 }
 /* }}} */
 
@@ -2447,11 +2448,15 @@
result = phpfbGetResult(resultIndex);
if (result == NULL) RETURN_FALSE;
 
-   rowCount = fbcmdRowCount (result->metaData);
-   if (rowCount == -1)
-   {
-   phpfbFetchRow(result,0x7fff);
+   if (result->array)
rowCount = result->rowCount;
+   else {
+   rowCount = fbcmdRowCount(result->metaData);
+   if (rowCount == -1)
+   {
+   phpfbFetchRow(result,0x7fff);
+   rowCount = result->rowCount;
+   }
}
return_value->value.lval = rowCount;
return_value->type   = IS_LONG;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-03-22 Thread Frank M. Kromann

fmk Thu Mar 22 16:58:59 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  Removing extra check for warnings.
  
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.6 php4/ext/fbsql/php_fbsql.c:1.7
--- php4/ext/fbsql/php_fbsql.c:1.6  Thu Mar 22 13:16:23 2001
+++ php4/ext/fbsql/php_fbsql.c  Thu Mar 22 16:58:59 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.6 2001/03/22 21:16:23 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.7 2001/03/23 00:58:59 fmk Exp $ */
 
 /* TODO:
  *
@@ -552,12 +552,12 @@
 }
 
 
-int phpfbFetchRow (PHPFBResult* result, int row)
+int phpfbFetchRow(PHPFBResult* result, int row)
 {
if (result->rowHandler == NULL)
{
-void *rawData = 
fbcdcFetch(result->connection,result->batchSize,result->fetchHandle);
-if (rawData == NULL)
+   void *rawData = 
+fbcdcFetch(result->connection,result->batchSize,result->fetchHandle);
+   if (rawData == NULL)
result->rowCount = 0;
else
result->rowHandler = fbcrhInitWith(rawData, result->metaData);
@@ -1513,26 +1513,6 @@
 
meta = fbcdcExecuteDirectSQL(database->connection,sql);
 
-   if (fbcmdErrorCount(meta) > 0) {
-   FBCErrorMetaData *errorMeta;
-   char *errorMessage;
-   unsigned error_type = 0;
-
-   errorMeta = fbcdcErrorMetaData(database->connection, meta);
-   error_type = fbcemdErrorCodeAtIndex(errorMeta, 0);
-   errorMessage = fbcemdAllErrorMessages(errorMeta);
-   if (error_type != 250) {
-   php_error(E_WARNING, "Error executing SQL-statement (%s)", 
sql);
-   }
-// free(errorMessage);
-   fbcemdRelease(errorMeta);
-
-   if (error_type != 250) {
-   fbcmdRelease(meta);
-   return NULL;
-   }
-   }
-
if (fbcmdHasMetaDataArray(meta)) {
sR = fbcmdMetaDataArrayCount(meta);
md = (FBCMetaData*)fbcmdMetaDataAtIndex(meta, cR);
@@ -1540,7 +1520,7 @@
else
md = meta;
 
-   ok = mdOk(database,md);
+   ok = mdOk(database, md);
tp = fbcmdStatementType(md);
 
return_value->value.lval = ok?-1:0;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-03-22 Thread Frank M. Kromann

fmk Thu Mar 22 13:16:23 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  Adding warning when query fails
  
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.5 php4/ext/fbsql/php_fbsql.c:1.6
--- php4/ext/fbsql/php_fbsql.c:1.5  Wed Mar 21 13:53:45 2001
+++ php4/ext/fbsql/php_fbsql.c  Thu Mar 22 13:16:23 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.5 2001/03/21 21:53:45 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.6 2001/03/22 21:16:23 fmk Exp $ */
 
 /* TODO:
  *
@@ -788,7 +788,6 @@
fbcdcClose(c);
fbcdcRelease(c);
free(result);
-/* printf("Returning Null\n"); */
return NULL;
}
result->retainCount  = 2;
@@ -813,7 +812,6 @@
link->databases[i] = result;
 
FB_SQL_G(databaseCount)++;
-/* printf("Return database %x %x\n",result,c); */
}
link->currentDatabase = result;
return_value->value.lval  = result->index;
@@ -1514,6 +1512,26 @@
FBSQLLS_FETCH();
 
meta = fbcdcExecuteDirectSQL(database->connection,sql);
+
+   if (fbcmdErrorCount(meta) > 0) {
+   FBCErrorMetaData *errorMeta;
+   char *errorMessage;
+   unsigned error_type = 0;
+
+   errorMeta = fbcdcErrorMetaData(database->connection, meta);
+   error_type = fbcemdErrorCodeAtIndex(errorMeta, 0);
+   errorMessage = fbcemdAllErrorMessages(errorMeta);
+   if (error_type != 250) {
+   php_error(E_WARNING, "Error executing SQL-statement (%s)", 
+sql);
+   }
+// free(errorMessage);
+   fbcemdRelease(errorMeta);
+
+   if (error_type != 250) {
+   fbcmdRelease(meta);
+   return NULL;
+   }
+   }
 
if (fbcmdHasMetaDataArray(meta)) {
sR = fbcmdMetaDataArrayCount(meta);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-03-21 Thread Frank M. Kromann

fmk Wed Mar 21 13:53:45 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  setting right params to zend_get_parameters_ex
  

Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.4 php4/ext/fbsql/php_fbsql.c:1.5
--- php4/ext/fbsql/php_fbsql.c:1.4  Wed Mar 21 11:56:33 2001
+++ php4/ext/fbsql/php_fbsql.c  Wed Mar 21 13:53:45 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.4 2001/03/21 19:56:33 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.5 2001/03/21 21:53:45 fmk Exp $ */
 
 /* TODO:
  *
@@ -584,7 +584,7 @@
FBSQLLS_FETCH();
 
if ((argc < 0) || (argc > 3)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc,&argv[0],&argv[1],&argv[2])==FAILURE) 
RETURN_FALSE;
+   if (zend_get_parameters_ex(argc,&argv[0],&argv[1],&argv[2])==FAILURE) 
+RETURN_FALSE;
if (argc >= 1)
{
convert_to_string_ex(argv[0]);
@@ -672,7 +672,7 @@
FBSQLLS_FETCH();
 
if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc, &argv[0])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc, &argv[0])==FAILURE) RETURN_FALSE;
if (argc == 1)
{
convert_to_long_ex(argv[0]);
@@ -851,7 +851,7 @@
FBSQLLS_FETCH();
 
if ((argc < 1) || (argc > 2)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc,&argv[0],&argv[1])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc,&argv[0],&argv[1])==FAILURE) RETURN_FALSE;
 
convert_to_long_ex(argv[0]);
phpLink = phpfbGetLink((*argv[0])->value.lval);
@@ -887,7 +887,7 @@
link = FB_SQL_G(linkIndex);
 
if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc,&argv[0],&argv[1])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc,&argv[0],&argv[1])==FAILURE) RETURN_FALSE;
 
if (argc == 1)
{
@@ -923,7 +923,7 @@
link = FB_SQL_G(linkIndex);
 
if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc,&argv[0],&argv[1])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc,&argv[0],&argv[1])==FAILURE) RETURN_FALSE;
 
if (argc == 1)
{
@@ -955,7 +955,7 @@
FBSQLLS_FETCH();
 
if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc, &argv[0])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc, &argv[0])==FAILURE) RETURN_FALSE;
 
phpfbestrdup(FB_SQL_G(hostName), &return_value->value.str.len, 
&return_value->value.str.val);
return_value->type = IS_STRING;
@@ -978,7 +978,7 @@
FBSQLLS_FETCH();
 
if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc, &argv[0])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc, &argv[0])==FAILURE) RETURN_FALSE;
 
phpfbestrdup(FB_SQL_G(databaseName), &return_value->value.str.len, 
&return_value->value.str.val);
return_value->type = IS_STRING;
@@ -1001,7 +1001,7 @@
FBSQLLS_FETCH();
 
if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc, &argv[0])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc, &argv[0])==FAILURE) RETURN_FALSE;
 
if (argc >= 1)
{
@@ -1022,7 +1022,7 @@
FBSQLLS_FETCH();
 
if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc, &argv[0])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc, &argv[0])==FAILURE) RETURN_FALSE;
 
phpfbestrdup(FB_SQL_G(userName), &return_value->value.str.len, 
&return_value->value.str.val);
return_value->type = IS_STRING;
@@ -1045,7 +1045,7 @@
FBSQLLS_FETCH();
 
if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc, &argv[0])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc, &argv[0])==FAILURE) RETURN_FALSE;
if (argc >= 1)
{
convert_to_string_ex(argv[0]);
@@ -1070,7 +1070,7 @@
name = FB_SQL_G(databaseName);
 
if ((argc < 1) || (argc > 2)) WRONG_PARAM_COUNT;
-   if (zend_get_parameters_ex(ht,argc, &argv[0],&argv[1])==FAILURE) RETURN_FALSE;
+   if (zend_get_parameters_ex(argc, &argv[0],&argv[1])==FAILURE) RETURN_FALSE;
 
if (argc >= 1)
{
@@ -1124,7 +1124,7 @@
databaseName = FB_SQL_G(databaseName);
 
if ((argc < 2) || (argc > 4)) WRONG_PARAM_COUNT;
-   if 
(zend_get_parameters_ex(ht,argc,&argv[0],&argv[1],&argv[2],&argv[3])==FAILURE) 
RETURN_FALSE;
+   if (zend_get_parameters_ex(argc,&argv[0],&argv[1],&argv[2],&argv[3])==FAILURE) 
+RETURN_FALSE;
 
convert_to_string_ex(argv[0]);
userName = (*argv[0])->value.str.val;
@@ -1177,7 +1177,7 @@
hostName = FB_S

[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-03-21 Thread Frank M. Kromann

fmk Wed Mar 21 11:56:34 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  changed arg types from pval* to zval**
  

Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.3 php4/ext/fbsql/php_fbsql.c:1.4
--- php4/ext/fbsql/php_fbsql.c:1.3  Tue Mar 20 12:25:55 2001
+++ php4/ext/fbsql/php_fbsql.c  Wed Mar 21 11:56:33 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.3 2001/03/20 20:25:55 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.4 2001/03/21 19:56:33 fmk Exp $ */
 
 /* TODO:
  *
@@ -249,156 +249,150 @@
 #endif
 
 
-void phpfbReleaseResult   ( PHPFBResult*   result );
-void phpfbReleaseDatabase ( PHPFBDatabase* database );
-void phpfbReleaseLink ( PHPFBLink* link );
+void phpfbReleaseResult   (PHPFBResult*   result);
+void phpfbReleaseDatabase (PHPFBDatabase* database);
+void phpfbReleaseLink (PHPFBLink* link);
 
-PHPFBResult* phpfbRetainResult ( PHPFBResult* result )
+PHPFBResult* phpfbRetainResult (PHPFBResult* result)
 {
if (result) result->retainCount++;
return result;
 }
 
-void phpfbReleaseResult ( PHPFBResult* result )
+void phpfbReleaseResult (PHPFBResult* result)
 {
unsigned int i;
FBSQLLS_FETCH();
if (result)
-{
+   {
result->retainCount--;
-/* printf("Release result   %x %d 
%d\n",result,result->index,result->retainCount); */
 
-  if (result->retainCount == 0)
-   {
- if (result->fetchHandle) 
fbcdcCancelFetch(result->connection,result->fetchHandle);
- if (result->rowHandler)  fbcrhRelease(result->rowHandler);
- if (result->ResultmetaData)fbcmdRelease(result->ResultmetaData);
+   if (result->retainCount == 0)
+   {
+   if (result->fetchHandle) 
+fbcdcCancelFetch(result->connection,result->fetchHandle);
+   if (result->rowHandler)  fbcrhRelease(result->rowHandler);
+   if (result->ResultmetaData)
+fbcmdRelease(result->ResultmetaData);
 /* if (result->metaData)fbcmdRelease(result->metaData);  */
- if (result->list)fbcplRelease(result->list);
- if (result->array)   fbaRelease(result->array);
- if ( result->database)
-  {
-for (i=0; i < result->database->resultCount; i++)
- {
-   if (result->database->results[i] == result)
-{
-  result->database->results[i] = NULL;
-  break;
-}
- }
-phpfbReleaseDatabase(result->database);
-  }
- if (result->link)
-  {
-for (i=0; i < result->link->resultCount; i++)
- {
-   if (result->link->results[i] == result)
-{
-  result->link->results[i] = NULL;
-  break;
-}
- }
-phpfbReleaseLink(result->link);
-  }
- result->link= 0;
- result->database= 0;
- result->connection  = NULL;
- result->fetchHandle = NULL;
- result->metaData= NULL;
- result->rowHandler  = NULL;
- result->batchSize   = 0;
- result->rowCount= -1;
- result->rowIndex= 0;
- result->columnIndex = 0;
- result->row = NULL;
- result->array   = NULL;
- result->list= NULL;
- free(result);
-   }
-}
+   if (result->list)fbcplRelease(result->list);
+   if (result->array)   fbaRelease(result->array);
+   if (result->database)
+   {
+   for (i=0; i < result->database->resultCount; i++)
+   {
+   if (result->database->results[i] == result)
+   {
+   result->database->results[i] = NULL;
+   break;
+   }
+   }
+   phpfbReleaseDatabase(result->database);
+   }
+   if (result->link)
+   {
+   for (i=0; i < result->link->resultCount; i++)
+   {
+   if (result->link->results[i] == result)
+   {
+   result->link->results[i] = NULL;
+   break;
+   }
+   }
+   phpfbReleaseLink(result->link);
+   }
+  

[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-03-20 Thread Frank M. Kromann

fmk Tue Mar 20 12:25:55 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  Fixing crash when result conrains 0 rows
  
Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.2 php4/ext/fbsql/php_fbsql.c:1.3
--- php4/ext/fbsql/php_fbsql.c:1.2  Tue Mar 20 11:21:45 2001
+++ php4/ext/fbsql/php_fbsql.c  Tue Mar 20 12:25:55 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.2 2001/03/20 19:21:45 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.3 2001/03/20 20:25:55 fmk Exp $ */
 
 /* TODO:
  *
@@ -2555,6 +2555,9 @@
if (result->fetchHandle == NULL) {
RETURN_FALSE;
}
+   if (result->rowCount == 0) {
+   RETURN_FALSE;
+   }
if (result->rowCount == 0x7fff) {
if (!phpfbFetchRow(result,rowIndex)) {
RETURN_FALSE;
@@ -2627,9 +2630,14 @@
{
RETURN_FALSE;
}
+   if (result->rowCount == 0) {
+   RETURN_FALSE;
+   }
if (result->rowCount == 0x7fff)
{
-   phpfbFetchRow(result,result->rowIndex);
+   if (!phpfbFetchRow(result,result->rowIndex)) {
+   RETURN_FALSE;
+   }
}
row = fbcrhRowAtIndex(result->rowHandler,rowIndex);
if (row == NULL)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /ext/fbsql php_fbsql.c

2001-03-20 Thread Frank M. Kromann

fmk Tue Mar 20 11:21:45 2001 EDT

  Modified files:  
/php4/ext/fbsql php_fbsql.c 
  Log:
  Converting to c-style comments.
  Adding prototypes to all exported function
  

Index: php4/ext/fbsql/php_fbsql.c
diff -u php4/ext/fbsql/php_fbsql.c:1.1 php4/ext/fbsql/php_fbsql.c:1.2
--- php4/ext/fbsql/php_fbsql.c:1.1  Tue Mar 13 12:58:47 2001
+++ php4/ext/fbsql/php_fbsql.c  Tue Mar 20 11:21:45 2001
@@ -7,7 +7,7 @@
| This source file is subject to version 2.02 of the PHP license,  |
| that is bundled with this package in the file LICENSE, and is|
| available at through the world-wide-web at   |
-   | http://www.php.net/license/2_02.txt. |
+   | http:/*www.php.net/license/2_02.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  |
| [EMAIL PROTECTED] so we can mail you a copy immediately.   |
@@ -16,27 +16,27 @@
+--+
  */
 
-/* $Id: php_fbsql.c,v 1.1 2001/03/13 20:58:47 fmk Exp $ */
+/* $Id: php_fbsql.c,v 1.2 2001/03/20 19:21:45 fmk Exp $ */
 
 /* TODO:
  *
  * ? Safe mode implementation
  */
 
-// SB's list:
-//   - BLOBs
-//   - API for a more natural FB connect semantic
-//   - Connect & set session 
-//   - Autoreconnect when disconnected
-//   - Comments and cleanup
-//   - Documentation
-//
-//   - Format database error messages as HTML.
-//
-// BUGS
-//   - Select db with no arguments
-//   - Query with everything defaulted
-//
+/* SB's list:
+   - BLOBs
+   - API for a more natural FB connect semantic
+   - Connect & set session 
+   - Autoreconnect when disconnected
+   - Comments and cleanup
+   - Documentation
+
+   - Format database error messages as HTML.
+
+   BUGS
+   - Select db with no arguments
+- Query with everything defaulted
+*/
 #include "php.h"
 #include "php_globals.h"
 #include "php_globals.h"
@@ -75,32 +75,32 @@
 struct PHPFBLink;
 typedef struct PHPFBLink PHPFBLink;
 
-// The PHPFBLink structure represents a fbsql link. The lion is used for
-// a connection to a machine, it may be persistant and is reference counted.
-// The reason for refcounting is mostly to avoid to think, it work independent of 
-// any wierd and unforseen allocation deallocation order.
-//
-// The PHPFBDatabse structure implements to actual connection to a FrontBase server
-// ot may be persistant is the link it is connected to is persistant, and refcounted
-// for the same reasons as above.
-//
-// The PHPFBResult structure implements a result from the FrontBase server, and does 
all
-// required buffereing from of results.
-//
-// In the PHP code the 3 above a data structures are referenced by means of integers 
in the
-// range from 1 to som configurable maximum.  You can put a limit to the number of 
links, databases
-// and results.  The integer identifications is implemented by insertion in the list, 
which is passed
-// as an argument to all the functions, please note the list is polymorph.
-//
-// Database objects and link objects are all reused, base on the host name user name, 
host name database name 
-// user name.  So connecting twice to the same database as the same user will return 
the same database id.
-// We use the same coding for that as fbsql does, explioiting the underlying 
implementation of the lists.
-//
-// Persistant objects are put in the persistent list as well, but only by name, if 
you connect to a persistant object
-// and it is not in the list it is simply added and get a new index, and refcounted.  
Tricky, tricky ...
-//
+/* The PHPFBLink structure represents a fbsql link. The lion is used for
+   a connection to a machine, it may be persistant and is reference counted.
+   The reason for refcounting is mostly to avoid to think, it work independent of 
+   any wierd and unforseen allocation deallocation order.
+
+   The PHPFBDatabse structure implements to actual connection to a FrontBase 
+server
+   ot may be persistant is the link it is connected to is persistant, and 
+refcounted
+   for the same reasons as above.
+
+   The PHPFBResult structure implements a result from the FrontBase server, and 
+does all
+   required buffereing from of results.
+
+   In the PHP code the 3 above a data structures are referenced by means of 
+integers in the
+   range from 1 to som configurable maximum.  You can put a limit to the number 
+of links, databases
+   and results.  The integer identifications is implemented by insertion in the 
+list, which is passed
+   as an argument to all the functions, please note the list is polymorph.
+
+   Database objects and link objects are all reused, base on the host name user 
+name, host name database name 
+