[PHP-DEV] Patch to interbase module.

2001-09-04 Thread Jeremy Bettis

Please apply this patch to the CVS archive, or give me a CVS account.  This
fixes a critical bug in interbase.

Summary of changes:
* The CVS version doesn't compile right now because of ibase_globals
weirdness. I fixed that.
* If a bind parameter (i.e. ? in a query) is NULL then pass a NULL to the
database instead of an empty string.
* If a date is not parsable, give a helpful error.
* If a string is passed as a bind parameter to a blob field, and the string
is not a blob handle, then create a new blob, write the string to it, and
give the database that blob handle.
* The MS Visual Studio .dsp file doesn't support building the Debug_TS
config.  I fixed it.
* IBG(v) was defined twice in php_interbase.h and I removed one.



If this patch is not applied, tell me why. I'm just going to keep posting it
until someone adds it.  This is really important stuff to anyone that is
going to use interbase in any serious way.
--
Jeremy Bettis
[EMAIL PROTECTED]


begin 666 php.diff
M26YD97@Z(5X=]I;G1EF)AV4O:6YT97)B87-E+F,-/3T]/3T]/3T]/3T]
M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]
M/3T]/3T]/3T]/0U20U,@9FEL93H@+W)E]S:71OGDOAP-]E'0O:6YT
M97)B87-E+VEN=5R8F%S92YC+'8-F5TFEE=FEN9R!R979IVEO;B Q+C8X
M#61I9F8@+74@+7(Q+C8X(EN=5R8F%S92YC#2TM+2!E'0O:6YT97)B87-E
M+VEN=5R8F%S92YC3$S($%U9R R,# Q(# W.C4U.C,S(TP,# P3$N-C@-
M*RLK(5X=]I;G1EF)AV4O:6YT97)B87-E+F,),S$@075G(#(P,#$@,3Z
M-#0Z-3$@+3 P,# -0$ @+3(U+#8@*S(U+#$R($! #2 -(\J#2 )0VAA;F=E
MSH-*PD),C P,2TP-2TS,3H@2F5R96UY($)E='1IR \:F5R96UY01E861B
M965F+F-O;3X-*PD)2T@268@82!B;]B(AA;F1L92!W87,@97AP96-T960@
M86YD('-O;65T:EN9R!E;'-E('=APTK0D)(!R96-E:79E9!CF5A=4@
M82!B;]B(%N9!A90@=AE('9A;'5E('1O(ET+@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T
M95]B;]B*$E7U-405154RP@)FEB7V)L;V(M/FQI;FLL(9I8E]B;]B+3YT
MF

Re: [PHP-DEV] Patch to interbase module.

2001-09-04 Thread Jeremy Bettis

Ok, I'll try it again.  The first post was just what cvs diff gave me.  Here
is one with the line endings converted.

I'll attach it and copy-paste it.

Index: ext/interbase/interbase.c
===
RCS file: /repository/php4/ext/interbase/interbase.c,v
retrieving revision 1.68
diff -u -r1.68 interbase.c
--- ext/interbase/interbase.c 13 Aug 2001 07:55:33 - 1.68
+++ ext/interbase/interbase.c 31 Aug 2001 17:44:51 -
@@ -25,6 +25,12 @@

 /*
  Changes:
+  2001-05-31: Jeremy Bettis [EMAIL PROTECTED]
+   - If a blob handle was expected and something else was
+ received create a blob and add the value to it.
+   - If the incoming argument to a bind parameter is NULL
+ then store a NULL in the database.
+   - More verbose date errors.
   1999-09-21: Ivo Panacek [EMAIL PROTECTED]
- added COMPILE_DL section
- more verbose php_info_ibase function
@@ -484,13 +490,13 @@
   STD_PHP_INI_ENTRY(ibase.timeformat, %H:%M:%S, PHP_INI_ALL,
OnUpdateString, cfg_timeformat, zend_ibase_globals, ibase_globals)
 PHP_INI_END()

-static void php_ibase_init_globals(TSRMLS_D)
+static void php_ibase_init_globals(zend_ibase_globals *ibase_globals)
 {
- IBG(timestampformat) = NULL;
- IBG(dateformat) = NULL;
- IBG(timeformat) = NULL;
- IBG(errmsg) = NULL;
- IBG(num_persistent) = 0;
+ ibase_globals-timestampformat = NULL;
+ ibase_globals-dateformat = NULL;
+ ibase_globals-timeformat = NULL;
+ ibase_globals-errmsg = NULL;
+ ibase_globals-num_persistent = 0;
 }

 PHP_MINIT_FUNCTION(ibase)
@@ -1118,7 +1124,7 @@

 /* {{{ _php_ibase_bind()
Bind parameter placeholders in a previously prepared query */
-static int _php_ibase_bind(XSQLDA *sqlda, pval **b_vars, BIND_BUF *buf)
+static int _php_ibase_bind(XSQLDA *sqlda, pval **b_vars, BIND_BUF *buf,
ibase_query *ib_query)
 {
  XSQLVAR *var;
  pval *b_var;
@@ -1131,6 +1137,15 @@
   var-sqlind  = buf[i].sqlind;
   b_var = b_vars[i];

+  if (b_var-type == IS_NULL) {
+   static char nothing[64];
+   static short null_flag = -1;
+   var-sqldata = nothing;
+   var-sqltype |= 1;
+   var-sqlind = null_flag;
+   if (var-sqllen  64)
+var-sqllen = 64;
+  } else
   switch(var-sqltype  ~1) {
case SQL_TEXT:  /* direct to variable */
case SQL_VARYING:
@@ -1208,7 +1223,7 @@
  n = sscanf(b_var-value.str.val, %d%*[/]%d%*[/]%d %d%*[:]%d%*[:]%d,
  t.tm_mon, t.tm_mday, t.tm_year,  t.tm_hour, t.tm_min,
t.tm_sec);
  if(n != 3  n != 6){
-  _php_ibase_module_error(invalid date/time format);
+  _php_ibase_module_error(invalid date/time format: Expected 3 or 6
fields, got %d. Use format m/d/Y H:i:s. You gave '%s', n,
b_var-value.str.val);
   return FAILURE;
  }
  t.tm_year -= 1900;
@@ -1266,12 +1281,38 @@
  if (b_var-type != IS_STRING
   || b_var-value.str.len != sizeof(ibase_blob_handle)
   || ((ibase_blob_handle *)(b_var-value.str.val))-bl_handle != 0) {
+  ibase_blob_handle *ib_blob;
+  TSRMLS_FETCH();
+
+  ib_blob = (ibase_blob_handle *) emalloc(sizeof(ibase_blob_handle));
+  ib_blob-trans_handle = ib_query-trans;
+  ib_blob-link = ib_query-link;
+  ib_blob-bl_handle = NULL;
+  if (isc_create_blob(IB_STATUS, ib_blob-link,
ib_blob-trans_handle, ib_blob-bl_handle, ib_blob-bl_qd)) {
+   efree(ib_blob);
+   _php_ibase_error();
+   return FAILURE;
+  }
+  convert_to_string(b_var);
+  if (isc_put_segment(IB_STATUS, ib_blob-bl_handle, (unsigned short)
b_var-value.str.len, b_var-value.str.val)) {
+   _php_ibase_error();
+   return FAILURE;
+  }
+  if (isc_close_blob(IB_STATUS, ib_blob-bl_handle)) {
+   _php_ibase_error();
+   return FAILURE;
+  }
+  ib_blob_id = ib_blob;
+  var-sqldata = (void ISC_FAR *)ib_blob_id-bl_qd;
+/*
   _php_ibase_module_error(invalid blob id string);
   return FAILURE;
- }
- ib_blob_id = (ibase_blob_handle *)b_var-value.str.val;
+*/
+ } else {
+  ib_blob_id = (ibase_blob_handle *)b_var-value.str.val;

- var-sqldata = (void ISC_FAR *)ib_blob_id-bl_qd;
+  var-sqldata = (void ISC_FAR *)ib_blob_id-bl_qd;
+ }
 }
break;
case SQL_ARRAY:
@@ -1383,7 +1424,7 @@
   in_sqlda = emalloc(XSQLDA_LENGTH(ib_query-in_sqlda-sqld));
   memcpy(in_sqlda, ib_query-in_sqlda,
XSQLDA_LENGTH(ib_query-in_sqlda-sqld));
   bind_buf = emalloc(sizeof(BIND_BUF) * ib_query-in_sqlda-sqld);
-  if (_php_ibase_bind(in_sqlda, args, bind_buf) == FAILURE) {
+  if (_php_ibase_bind(in_sqlda, args, bind_buf, ib_query) == FAILURE) {
IBDEBUG(Could not bind input XSQLDA... (_php_ibase_exec));
goto _php_ibase_exec_error;
   }
Index: ext/interbase/interbase.dsp
===
RCS file: /repository/php4/ext/interbase/interbase.dsp,v
retrieving revision 1.5
diff -u -r1.5 interbase.dsp
--- ext/interbase/interbase.dsp 24 Aug 2000 18:58:50 - 1.5
+++ ext/interbase/interbase.dsp 31 Aug 2001 17:44:51 -
@@ -44,7 +44,7

[PHP-DEV] object to string convertion patch

2001-08-22 Thread Jeremy Bettis

I changed php (current CVS) to add another magic method to Objects,
__toString().  Whenever an object needs to be converted to a string, then it
will first try to call __toString() and if it can't, then it will just
return Object like now.

Please look over my patch and see if I did it correctly, and could someone
please put it in cvs? If someone will include this in CVS I will followup
with __toDouble() and __toLong() and __toBoolean() and __toArray()

My goal is to make Objects more useful as regular data types.  For example I
could introduce a new Class called Date which would act just like a string
in all string contexts and act just like a number of seconds from 1970 in
numeric contexts.

I have one thing that is confusing to me, look at this test script:

?php

class foo {
var $fooval;
function foo() {
$this-fooval=foofoo;
}
}

class bar extends foo {
function __toString() {
return 5;
}
}

class baz extends foo {
function __toString() {
return $this-fooval;
}
}

echo brbrbrbr\n;

$foo=new foo();
$bar=new bar();
$baz=new baz();

var_dump(5);
var_dump(strval(5));

echo print_r(\$foo): ; print_r($foo); echo br\n;
echo \$foo: , $foo, br\n;
echo strval(\$foo): , strval($foo), br\n;
echo var_dump(strval(\$foo)): ; var_dump(strval($foo)); echo br\n;
echo print_r(strval(\$foo)): ; print_r(strval($foo)); echo br\n;
echo print_r(\$bar): ; print_r($bar); echo br\n;
echo \$bar: , $bar, br\n;
echo strval(\$bar): , strval($bar), br\n;
echo var_dump(strval(\$bar)): ; var_dump(strval($bar)); echo br\n;
echo print_r(strval(\$bar)): ; print_r(strval($bar)); echo br\n;
echo print_r(\$baz): ; print_r($baz); echo br\n;
echo \$baz: , $baz, br\n;
echo strval(\$baz): , strval($baz), br\n;
echo var_dump(strval(\$baz)): ; var_dump(strval($baz)); echo br\n;
echo print_r(strval(\$baz)): ; print_r(strval($baz)); echo br\n;

 ?



Everything works as expected except for the var_dump and print_r calls.
Here is the output:
Notice the the print_r calls are showing the whole object and not just the
strval.

int(5) string(1) 5 print_r($foo): foo Object ( [fooval] = foofoo )
$foo:
Warning: Object to string conversion in c:\inetpub\wwwroot\default.php on
line 37
Object
strval($foo):
Warning: Object to string conversion in c:\inetpub\wwwroot\default.php on
line 38
Object
var_dump(strval($foo)):
Warning: Object to string conversion in c:\inetpub\wwwroot\default.php on
line 39
string(6) Object
print_r(strval($foo)):
Warning: Object to string conversion in c:\inetpub\wwwroot\default.php on
line 40
Object
print_r($bar): bar Object ( [fooval] = foofoo )
$bar: 5
strval($bar): 5
var_dump(strval($bar)): object(bar)(1) { [fooval]= string(6) foofoo }
print_r(strval($bar)): bar Object ( [fooval] = foofoo )
print_r($baz): baz Object ( [fooval] = foofoo )
$baz: foofoo
strval($baz): foofoo
var_dump(strval($baz)): object(baz)(1) { [fooval]= string(6) foofoo }
print_r(strval($baz)): baz Object ( [fooval] = foofoo )





begin 666 foo.txt
M26YD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OG,N8PTM+2T@
M6F5N9]Z96YD7V]P97)A=]RRYC3(P,#$O,#@O,30@,3$Z,34Z,#@),2XQ
M,3(-*RLK(%IE;F0OF5N9%]O5R871OG,N8PDR,# Q+S X+S(R(#$V.C,Y
M.C0U#4! (TT-C8L,3$@*S0V-BPR.! 0 T@0D)F5N9%]EG)OBA%7TY/
M5$E#12P@(D%RF%Y('1O('-TFEN9R!C;VYV97)S:6]N(BD[#2 )0EBF5A
M:SL-( D)8V%S92!)4U]/0DI%0U0Z#2T)0EZ=F%L7V1T;W(H;W I.PTM0D)
M;W M/G9A;'5E+G-TBYV86P@/2!EW1R;F1U%]R96PH(D]B:F5C=(L('-I
MF5O9B@B3V)J96-T(BDM,2D[#2T)0EOT^=F%L=64NW1R+FQE;B ]('-I
MF5O9B@B3V)J96-T(BDM,3L-+0D)7IE;F1?97)R;W(H15].3U1)0T4L()/
M8FIE8W0@=\@W1R:6YG(-O;G9EG-I;VXB*3L-*PD)PTK0D@( @G9A
M; JW1R=F%L.PTK0D@( @G9A; J9G5N8U]N86UE.PTK( @( @( @
M( @04Q,3T-?6E9!3AF=6YC7VYA;64I.PTK( @( @( @( @04Q,3T-?
M6E9!3AS=')V86PI.PTK0D@( @6E9!3%]35%))3DH9G5N8U]N86UE+ B
M7U]T;U-TFEN9R(L(#$I.PTK( @( @( @( @:68H8V%L;%]UV5R7V9U
M;F-T:6]N7V5X*$Y53$PL(9OP@9G5N8U]N86UE+ FW1R=F%L+ P+!.
M54Q,+ P+!.54Q,(%134DU,4U]#0RD@(3T@4U5#0T534R!\?!S=')V86PM
M/G1Y4@/3T@25-?3T)*14-4*0TK( @( @( @( @PTK0D)( @('IV

Re: [PHP-DEV] object to string convertion patch

2001-08-22 Thread Jeremy Bettis

My implementation does not have these inconsistencies (I looked in the
archives).  The only wierd thing is print_r and dump_var.

Zeev Suraski [EMAIL PROTECTED] wrote in message
5.1.0.14.2.20010822195524.03aeb4c8@localhost">news:5.1.0.14.2.20010822195524.03aeb4c8@localhost...
 At 19:53 22-08-01, Andrei Zmievski wrote:
 On Wed, 22 Aug 2001, Jeremy Bettis wrote:
   I changed php (current CVS) to add another magic method to Objects,
   __toString().  Whenever an object needs to be converted to a string,
  then it
   will first try to call __toString() and if it can't, then it will just
   return Object like now.
 
 Good luck trying to get this in.

 I implemented this once, and it was even in for several mini versions.
But
 it causes inconsistencies, and it was thus removed (I don't remember what
 the inconsistencies were, look up the archives...)

 Zeev




-- 
PHP Development 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-DEV] Is there any value in having functions defined which do nothing.

2001-07-10 Thread Jeremy Bettis

Why is the habit of PHP modules to define functions that might or might not
work depending on library dependancies.

For example, ImageCopyResampled gives this error if libgd  2.0:
ImageCopyResampled required libgd 2.0

But that makes this code useless:

if (function_exists('ImageCopyResampled')) {
// doit the good way
ImageCopyResampled(.);
} else {
ImageCopyResized(.);
}

My point was to have the php script work regardless of what version of php
was installed, but even if the function exists, it might not work.  Wouldn't
it have been better if the function just didn't exist at all?
--
Jeremy Bettis
[EMAIL PROTECTED]



-- 
PHP Development 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-DEV] Transparent use of blobs in Interbase

2001-07-06 Thread Jeremy Bettis

 Can you send this patch to the list as an attachment? It's a little messed
 up due to line endings.

Here you are.


Index: ext/interbase/interbase.c
===
RCS file: /repository/php4/ext/interbase/interbase.c,v
retrieving revision 1.58
diff -u -r1.58 interbase.c
--- ext/interbase/interbase.c   2001/06/09 09:30:42 1.58
+++ ext/interbase/interbase.c   2001/07/06 14:59:01
@@ -25,6 +25,15 @@
 
 /*
Changes:
+   2001-06-13: Jeremy Bettis [EMAIL PROTECTED]
+   - Return the text of blobs in _php_ibase_fetch_hash, not the blob
+ handles, even if the BLOB is not of TEXT type
+   2001-05-31: Jeremy Bettis [EMAIL PROTECTED]
+   - If a blob handle was expected and something else was
+ received create a blob and add the value to it.
+   - If the incoming argument to a bind parameter is NULL
+ then store a NULL in the database.
+   - More verbose date errors.
1999-09-21: Ivo Panacek [EMAIL PROTECTED]
- added COMPILE_DL section
- more verbose php_info_ibase function
@@ -1130,7 +1139,7 @@
 
 /* {{{ _php_ibase_bind()
Bind parameter placeholders in a previously prepared query */
-static int _php_ibase_bind(XSQLDA *sqlda, pval **b_vars, BIND_BUF *buf)
+static int _php_ibase_bind(XSQLDA *sqlda, pval **b_vars, BIND_BUF *buf, ibase_query 
+*ib_query)
 {
XSQLVAR *var;
pval *b_var;
@@ -1143,6 +1152,15 @@
var-sqlind  = buf[i].sqlind;
b_var = b_vars[i];

+   if (b_var-type == IS_NULL) {
+   static char nothing[64];
+   static short null_flag = -1;
+   var-sqldata = nothing;
+   var-sqltype |= 1;
+   var-sqlind = null_flag;
+   if (var-sqllen  64)
+   var-sqllen = 64;
+   } else
switch(var-sqltype  ~1) {
case SQL_TEXT: /* direct to variable */
case SQL_VARYING:
@@ -1220,7 +1238,7 @@
n = 
sscanf(b_var-value.str.val,%d%*[/]%d%*[/]%d %d%*[:]%d%*[:]%d,
   t.tm_mon, t.tm_mday, t.tm_year,  
t.tm_hour, t.tm_min, t.tm_sec);
if(n != 3  n != 6){
-   _php_ibase_module_error(invalid 
date/time format);
+   _php_ibase_module_error(invalid 
+date/time format: Expected 3 or 6 fields, got %d. Use format m/d/Y H:i:s. You gave 
+'%s', n, b_var-value.str.val);
return FAILURE;
}
t.tm_year -= 1900;
@@ -1278,12 +1296,36 @@
if (b_var-type != IS_STRING
|| b_var-value.str.len != 
sizeof(ibase_blob_handle)
|| ((ibase_blob_handle 
*)(b_var-value.str.val))-bl_handle != 0) {
+   IBLS_FETCH();
+   ibase_blob_handle *ib_blob;
+   ib_blob = (ibase_blob_handle *) 
+emalloc(sizeof(ibase_blob_handle));
+   ib_blob-trans_handle = 
+ib_query-trans;
+   ib_blob-link = ib_query-link;
+   ib_blob-bl_handle = NULL;
+   if (isc_create_blob(IB_STATUS, 
+ib_blob-link, ib_blob-trans_handle, ib_blob-bl_handle, ib_blob-bl_qd)) {
+   efree(ib_blob);
+   _php_ibase_error();
+   return FAILURE;
+   }
+   convert_to_string(b_var);
+   if (isc_put_segment(IB_STATUS, 
+ib_blob-bl_handle, (unsigned short) b_var-value.str.len, b_var-value.str.val)) {
+   _php_ibase_error();
+   return FAILURE;
+   }
+   if (isc_close_blob(IB_STATUS, 
+ib_blob-bl_handle)) {
+   _php_ibase_error();
+   return FAILURE

[PHP-DEV] Re: Bug #11819 Updated: Bug with ibase_execute()

2001-07-06 Thread Jeremy Bettis

The patch that I just posted to the list fixes this problem.  Nulls passed
as ? parameters were being sent to interbase as 0's.

--
Jeremy Bettis
[EMAIL PROTECTED]

[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 ID: 11819
 User Update by: [EMAIL PROTECTED]
 Status: Bogus
 Bug Type: InterBase related
 Operating system: Windows 2000
 PHP Version: 4.0.6
 Description: Bug with ibase_execute()




-- 
PHP Development 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-DEV] Building PHP with freetype and libgd 1.8

2001-07-05 Thread Jeremy Bettis


I had trouble building cvs version of PHP with libfreetype.  Right now
HAVE_LIBFREETYPE only works if HAVE_LIBGD20, this patch fixes that.

Index: ext/gd/gd.c
===
RCS file: /repository/php4/ext/gd/gd.c,v
retrieving revision 1.138
diff -u -r1.138 gd.c
--- ext/gd/gd.c 2001/07/02 12:49:21 1.138
+++ ext/gd/gd.c 2001/07/05 19:12:41
@@ -2659,7 +2659,7 @@
  fontname = (unsigned char *) Z_STRVAL_PP(FONTNAME);

 #ifdef USE_GD_IMGSTRTTF
-# if HAVE_LIBGD20  HAVE_LIBFREETYPE
+# if HAVE_LIBFREETYPE
  error = gdImageStringFT(im, brect, col, fontname, ptsize, angle, x, y,
str);
 # else
  error = gdImageStringTTF(im, brect, col, fontname, ptsize, angle, x, y,
str);

--
Jeremy Bettis
[EMAIL PROTECTED]



-- 
PHP Development 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-DEV] Transparent use of blobs in Interbase

2001-07-05 Thread Jeremy Bettis

This patch will make it so that no special effort is required to use blobs
in interbase.  Since the blob functions don't seem to work right anyway, I
see no reason that you should not include this patch.  (patch against
current cvs)


Index: ext/interbase/interbase.c
===
RCS file: /repository/php4/ext/interbase/interbase.c,v
retrieving revision 1.58
diff -u -r1.58 interbase.c
--- ext/interbase/interbase.c 2001/06/09 09:30:42 1.58
+++ ext/interbase/interbase.c 2001/07/05 19:12:46
@@ -25,6 +25,15 @@

 /*
  Changes:
+ 2001-06-13: Jeremy Bettis [EMAIL PROTECTED]
+ - Return the text of blobs in _php_ibase_fetch_hash, not the blob
+   handles, even if the BLOB is not of TEXT type
+  2001-05-31: Jeremy Bettis [EMAIL PROTECTED]
+   - If a blob handle was expected and something else was
+ received create a blob and add the value to it.
+   - If the incoming argument to a bind parameter is NULL
+ then store a NULL in the database.
+   - More verbose date errors.
   1999-09-21: Ivo Panacek [EMAIL PROTECTED]
- added COMPILE_DL section
- more verbose php_info_ibase function
@@ -1130,7 +1139,7 @@

 /* {{{ _php_ibase_bind()
Bind parameter placeholders in a previously prepared query */
-static int _php_ibase_bind(XSQLDA *sqlda, pval **b_vars, BIND_BUF *buf)
+static int _php_ibase_bind(XSQLDA *sqlda, pval **b_vars, BIND_BUF *buf,
ibase_query *ib_query)
 {
  XSQLVAR *var;
  pval *b_var;
@@ -1143,6 +1152,15 @@
   var-sqlind  = buf[i].sqlind;
   b_var = b_vars[i];

+  if (b_var-type == IS_NULL) {
+   static char nothing[64];
+   static short null_flag = -1;
+   var-sqldata = nothing;
+   var-sqltype |= 1;
+   var-sqlind = null_flag;
+   if (var-sqllen  64)
+var-sqllen = 64;
+  } else
   switch(var-sqltype  ~1) {
case SQL_TEXT:  /* direct to variable */
case SQL_VARYING:
@@ -1220,7 +1238,7 @@
  n = sscanf(b_var-value.str.val,%d%*[/]%d%*[/]%d %d%*[:]%d%*[:]%d,
  t.tm_mon, t.tm_mday, t.tm_year,  t.tm_hour, t.tm_min,
t.tm_sec);
  if(n != 3  n != 6){
-  _php_ibase_module_error(invalid date/time format);
+  _php_ibase_module_error(invalid date/time format: Expected 3 or 6
fields, got %d. Use format m/d/Y H:i:s. You gave '%s', n,
b_var-value.str.val);
   return FAILURE;
  }
  t.tm_year -= 1900;
@@ -1278,12 +1296,36 @@
  if (b_var-type != IS_STRING
   || b_var-value.str.len != sizeof(ibase_blob_handle)
   || ((ibase_blob_handle *)(b_var-value.str.val))-bl_handle != 0) {
+  IBLS_FETCH();
+  ibase_blob_handle *ib_blob;
+  ib_blob = (ibase_blob_handle *) emalloc(sizeof(ibase_blob_handle));
+  ib_blob-trans_handle = ib_query-trans;
+  ib_blob-link = ib_query-link;
+  ib_blob-bl_handle = NULL;
+  if (isc_create_blob(IB_STATUS, ib_blob-link,
ib_blob-trans_handle, ib_blob-bl_handle, ib_blob-bl_qd)) {
+   efree(ib_blob);
+   _php_ibase_error();
+   return FAILURE;
+  }
+  convert_to_string(b_var);
+  if (isc_put_segment(IB_STATUS, ib_blob-bl_handle, (unsigned short)
b_var-value.str.len, b_var-value.str.val)) {
+   _php_ibase_error();
+   return FAILURE;
+  }
+  if (isc_close_blob(IB_STATUS, ib_blob-bl_handle)) {
+   _php_ibase_error();
+   return FAILURE;
+  }
+  ib_blob_id = ib_blob;
+  var-sqldata = (void ISC_FAR *)ib_blob_id-bl_qd;
+/*
   _php_ibase_module_error(invalid blob id string);
   return FAILURE;
+*/
+ } else {
+  ib_blob_id = (ibase_blob_handle *)b_var-value.str.val;
+  var-sqldata = (void ISC_FAR *)ib_blob_id-bl_qd;
  }
- ib_blob_id = (ibase_blob_handle *)b_var-value.str.val;
-
- var-sqldata = (void ISC_FAR *)ib_blob_id-bl_qd;
 }
break;
case SQL_ARRAY:
@@ -1395,7 +1437,7 @@
   in_sqlda = emalloc(XSQLDA_LENGTH(ib_query-in_sqlda-sqld));
   memcpy(in_sqlda, ib_query-in_sqlda,
XSQLDA_LENGTH(ib_query-in_sqlda-sqld));
   bind_buf = emalloc(sizeof(BIND_BUF) * ib_query-in_sqlda-sqld);
-  if (_php_ibase_bind(in_sqlda, args, bind_buf) == FAILURE) {
+  if (_php_ibase_bind(in_sqlda, args, bind_buf, ib_query) == FAILURE) {
IBDEBUG(Could not bind input XSQLDA... (_php_ibase_exec));
goto _php_ibase_exec_error;
   }
@@ -1961,7 +2003,7 @@
  _php_ibase_var_pval(tmp, var-sqldata, var-sqltype, var-sqllen,
var-sqlscale, flag);
  break;
 case SQL_BLOB:
- if (flag  PHP_IBASE_TEXT) { /* text ? */
+ if (1 /*flag  PHP_IBASE_TEXT*/) { /* text ? */
   int stat;
   isc_blob_handle bl_handle = NULL;
   ISC_LONG max_len = 0, cur_len = 0;


--
Jeremy Bettis
[EMAIL PROTECTED]



-- 
PHP Development 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]