@@ -787,35 +787,54 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval *b_vars, BIND_BUF *buf, /* {{{ */
787787 }
788788 continue ;
789789
790- case SQL_BOOLEAN :
791-
792- convert_to_string (b_var );
793- var -> sqldata = Z_STRVAL_P (b_var );
794- var -> sqllen = Z_STRLEN_P (b_var );
795- var -> sqltype = SQL_BOOLEAN ;
796- continue ;
797-
798- if (Z_STRLEN_P (b_var ) != BLOB_ID_LEN ||
799- !_php_ibase_string_to_quad (Z_STRVAL_P (b_var ), & buf [i ].val .qval )) {
800-
801- ibase_blob ib_blob = { 0 , BLOB_INPUT };
802-
803- if (isc_create_blob (IB_STATUS , & ib_query -> link -> handle ,
804- & ib_query -> trans -> handle , & ib_blob .bl_handle , & ib_blob .bl_qd )) {
805- _php_ibase_error ();
806- return FAILURE ;
807- }
790+ case SQL_BOOLEAN :
791+
792+ switch (Z_TYPE_P (b_var )) {
793+ case IS_LONG :
794+ case IS_DOUBLE :
795+ case IS_TRUE :
796+ case IS_FALSE :
797+ * (bool * )var -> sqldata = zend_is_true (b_var ) ? 1 : 0 ;
798+ break ;
799+ case IS_STRING :
800+ {
801+ zend_long lval ;
802+ double dval ;
808803
809- if (_php_ibase_blob_add (b_var , & ib_blob ) != SUCCESS ) {
810- return FAILURE ;
811- }
804+ if ((Z_STRLEN_P (b_var ) == 0 )) {
805+ * (bool * )var -> sqldata = 0 ;
806+ break ;
807+ }
812808
813- if (isc_close_blob (IB_STATUS , & ib_blob .bl_handle )) {
814- _php_ibase_error ();
815- return FAILURE ;
809+ switch (is_numeric_string (Z_STRVAL_P (b_var ), Z_STRLEN_P (b_var ), & lval , & dval , 0 )) {
810+ case IS_LONG :
811+ * (bool * )var -> sqldata = (lval != 0 ) ? 1 : 0 ;
812+ break ;
813+ case IS_DOUBLE :
814+ * (bool * )var -> sqldata = (dval != 0 ) ? 1 : 0 ;
815+ break ;
816+ default :
817+ if (!zend_binary_strncasecmp (Z_STRVAL_P (b_var ), Z_STRLEN_P (b_var ), "true" , 4 , 4 )) {
818+ * (bool * )var -> sqldata = 1 ;
819+ } else if (!zend_binary_strncasecmp (Z_STRVAL_P (b_var ), Z_STRLEN_P (b_var ), "false" , 5 , 5 )) {
820+ * (bool * )var -> sqldata = 1 ;
821+ } else {
822+ _php_ibase_module_error ("Parameter %d: cannot convert string to boolean" , i + 1 );
823+ rv = FAILURE ;
824+ continue ;
825+ }
826+ }
827+ break ;
816828 }
817- buf [i ].val .qval = ib_blob .bl_qd ;
829+ case IS_NULL :
830+ buf [i ].sqlind = -1 ;
831+ break ;
832+ default :
833+ _php_ibase_module_error ("Parameter %d: must be boolean" , i + 1 );
834+ rv = FAILURE ;
835+ continue ;
818836 }
837+ var -> sqltype = SQL_BOOLEAN ;
819838 continue ;
820839
821840 case SQL_ARRAY :
0 commit comments