⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sql_relay.c

📁 适合于Unix/Linux下的一个持久数据库连接池
💻 C
📖 第 1 页 / 共 4 页
字号:
		if (Z_TYPE_PP(value)==IS_STRING) {			convert_to_string_ex(value);			cursor->substitution((*variable)->value.str.val,(*value)->value.str.val);			RETURN_LONG(1);		} else if (Z_TYPE_PP(value)==IS_LONG) {			convert_to_long_ex(value);			cursor->substitution((*variable)->value.str.val,(*value)->value.lval);			RETURN_LONG(1);		} else if (ZEND_NUM_ARGS()==5 && Z_TYPE_PP(value)==IS_DOUBLE) {			convert_to_double_ex(value);			cursor->substitution((*variable)->value.str.val,(*value)->value.dval,(unsigned short)(*precision)->value.lval,(unsigned short)(*scale)->value.lval);			RETURN_LONG(1);		} else if (Z_TYPE_PP(value)==IS_NULL) {			cursor->substitution((*variable)->value.str.val,(const char *)NULL);			RETURN_LONG(1);		}	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_clearbinds) {	zval **sqlrcur;	if (ZEND_NUM_ARGS() != 1 || 		zend_get_parameters_ex(1,&sqlrcur) == FAILURE) {		WRONG_PARAM_COUNT;	}	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->clearBinds();	}}DLEXPORT ZEND_FUNCTION(sqlrcur_countbindvariables) {	zval **sqlrcur;	uint16_t r;	if (ZEND_NUM_ARGS() != 1 || 		zend_get_parameters_ex(1,&sqlrcur) == FAILURE) {		WRONG_PARAM_COUNT;	}	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->countBindVariables();		RETURN_LONG(r);	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_inputbind) {	zval **sqlrcur,**variable,**value,**precision,**scale;	if (ZEND_NUM_ARGS() != 3 || 		zend_get_parameters_ex(3,&sqlrcur,&variable,&value) 					== FAILURE) {		if (ZEND_NUM_ARGS() != 5 || 			zend_get_parameters_ex(5,&sqlrcur,				&variable,&value,&precision,&scale)== FAILURE) {			WRONG_PARAM_COUNT;		}	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		if (Z_TYPE_PP(value)==IS_STRING) {			convert_to_string_ex(value);			cursor->inputBind((*variable)->value.str.val,(*value)->value.str.val);			RETURN_LONG(1);		} else if (Z_TYPE_PP(value)==IS_LONG) {			convert_to_long_ex(value);			cursor->inputBind((*variable)->value.str.val,(*value)->value.lval);			RETURN_LONG(1);		} else if (ZEND_NUM_ARGS()==5 && Z_TYPE_PP(value)==IS_DOUBLE) {			convert_to_double_ex(value);			cursor->inputBind((*variable)->value.str.val,(*value)->value.dval,(unsigned short)(*precision)->value.lval,(unsigned short)(*scale)->value.lval);			RETURN_LONG(1);		} else if (Z_TYPE_PP(value)==IS_NULL) {			cursor->inputBind((*variable)->value.str.val,(const char *)NULL);			RETURN_LONG(1);		}	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_inputbindblob) {	zval **sqlrcur,**variable,**value,**size;	if (ZEND_NUM_ARGS() != 4 || 		zend_get_parameters_ex(4,&sqlrcur,&variable,&value,&size) 					== FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	convert_to_string_ex(value);	convert_to_long_ex(size);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->inputBindBlob((*variable)->value.str.val,(*value)->value.str.val,(*size)->value.lval);		RETURN_LONG(1);	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_inputbindclob) {	zval **sqlrcur,**variable,**value,**size;	if (ZEND_NUM_ARGS() != 4 || 		zend_get_parameters_ex(4,&sqlrcur,&variable,&value,&size) 					== FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	convert_to_string_ex(value);	convert_to_long_ex(size);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->inputBindClob((*variable)->value.str.val,(*value)->value.str.val,(*size)->value.lval);		RETURN_LONG(1);	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindstring) {	zval **sqlrcur,**variable,**length;	if (ZEND_NUM_ARGS() != 3 || 		zend_get_parameters_ex(3,&sqlrcur,&variable,&length) 					== FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	convert_to_long_ex(length);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->defineOutputBindString((*variable)->value.str.val,(*length)->value.lval);	}}DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindinteger) {	zval **sqlrcur,**variable;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->defineOutputBindInteger((*variable)->value.str.val);	}}DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbinddouble) {	zval **sqlrcur,**variable;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->defineOutputBindDouble((*variable)->value.str.val);	}}DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindblob) {	zval **sqlrcur,**variable;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) 					== FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->defineOutputBindBlob((*variable)->value.str.val);	}}DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindclob) {	zval **sqlrcur,**variable;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) 					== FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->defineOutputBindClob((*variable)->value.str.val);	}}DLEXPORT ZEND_FUNCTION(sqlrcur_defineoutputbindcursor) {	zval **sqlrcur,**variable;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) 					== FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->defineOutputBindCursor((*variable)->value.str.val);	}}DLEXPORT ZEND_FUNCTION(sqlrcur_substitutions) {	zval **sqlrcur,**variables,**values,**precisions,**scales,**var,**val,**precision,**scale;	unsigned int i;	if (ZEND_NUM_ARGS() != 3 ||		zend_get_parameters_ex(3,&sqlrcur,&variables,&values) 					== FAILURE) {		if (ZEND_NUM_ARGS() != 5 || 			zend_get_parameters_ex(5,&sqlrcur,				&variables,&values,				&precisions,&scales)== FAILURE) {			WRONG_PARAM_COUNT;		} else {			convert_to_array_ex(precisions);			convert_to_array_ex(scales);		}	}	convert_to_array_ex(variables);	convert_to_array_ex(values);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	long	success=1;	if (cursor) {		for (i=0; i<(*variables)->value.ht->nNumOfElements; i++) {			zend_hash_index_find((*variables)->value.ht,i,(void **)&var);			zend_hash_index_find((*values)->value.ht,i,(void **)&val);			if (Z_TYPE_PP(val)==IS_STRING) {				convert_to_string_ex(val);				cursor->substitution((*var)->value.str.val,(*val)->value.str.val);			} else if (Z_TYPE_PP(val)==IS_LONG) {				convert_to_long_ex(val);				cursor->substitution((*var)->value.str.val,(*val)->value.lval);			} else if (ZEND_NUM_ARGS()==5 && Z_TYPE_PP(val)==IS_DOUBLE) {				zend_hash_index_find((*precisions)->value.ht,i,								(void **)&precision);				zend_hash_index_find((*scales)->value.ht,i,								(void **)&scale);				convert_to_double_ex(val);				convert_to_long_ex(precision);				convert_to_long_ex(scale);				cursor->substitution((*var)->value.str.val,(*val)->value.dval,(unsigned short)(*precision)->value.lval,(unsigned short)(*scale)->value.lval);			} else if (Z_TYPE_PP(val)==IS_NULL) {				cursor->substitution((*var)->value.str.val,(const char *)NULL);			} else {				success=0;			}		}	}	RETURN_LONG(success);}DLEXPORT ZEND_FUNCTION(sqlrcur_inputbinds) {	zval **sqlrcur,**variables,**values,**precisions,**scales,**var,**val,**precision,**scale;	int i;	if (ZEND_NUM_ARGS() != 3 ||		zend_get_parameters_ex(3,&sqlrcur,&variables,&values) 					== FAILURE) {		if (ZEND_NUM_ARGS() != 5 || 			zend_get_parameters_ex(5,&sqlrcur,				&variables,&values,				&precisions,&scales)== FAILURE) {			WRONG_PARAM_COUNT;		} else {			convert_to_array_ex(precisions);			convert_to_array_ex(scales);		}	}	convert_to_array_ex(variables);	convert_to_array_ex(values);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	long	success=1;	if (cursor) {		for (i=0; i<zend_hash_num_elements((*variables)->value.ht); i++) {			zend_hash_index_find((*variables)->value.ht,i,(void **)&var);			zend_hash_index_find((*values)->value.ht,i,(void **)&val);			if (Z_TYPE_PP(val)==IS_STRING) {				convert_to_string_ex(val);				cursor->inputBind((*var)->value.str.val,(*val)->value.str.val);			} else if (Z_TYPE_PP(val)==IS_LONG) {				convert_to_long_ex(val);				cursor->inputBind((*var)->value.str.val,(*val)->value.lval);			} else if (ZEND_NUM_ARGS()==5 && Z_TYPE_PP(val)==IS_DOUBLE) {				zend_hash_index_find((*precisions)->value.ht,i,								(void **)&precision);				zend_hash_index_find((*scales)->value.ht,i,								(void **)&scale);				convert_to_long_ex(precision);				convert_to_long_ex(scale);				convert_to_double_ex(val);				cursor->inputBind((*var)->value.str.val,(*val)->value.dval,(unsigned short)(*precision)->value.lval,(unsigned short)(*scale)->value.lval);			} else if (Z_TYPE_PP(val)==IS_NULL) {				cursor->inputBind((*var)->value.str.val,(const char *)NULL);			} else {				success=0;			}		}	}	RETURN_LONG(success);}DLEXPORT ZEND_FUNCTION(sqlrcur_validatebinds) {	zval **sqlrcur;	if (ZEND_NUM_ARGS() != 1 || 		zend_get_parameters_ex(1,&sqlrcur) == FAILURE) {		WRONG_PARAM_COUNT;	}	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		cursor->validateBinds();	}}DLEXPORT ZEND_FUNCTION(sqlrcur_validbind) {	zval **sqlrcur,**variable;	bool r;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->validBind((*variable)->value.str.val);		RETURN_LONG(r);	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_executequery) {	zval **sqlrcur;	bool r;	if (ZEND_NUM_ARGS() != 1 || 		zend_get_parameters_ex(1,&sqlrcur) == FAILURE) {		WRONG_PARAM_COUNT;	}	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->executeQuery();		RETURN_LONG(r);	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_fetchfrombindcursor) {	zval **sqlrcur;	bool r;	if (ZEND_NUM_ARGS() != 1 || 		zend_get_parameters_ex(1,&sqlrcur) == FAILURE) {		WRONG_PARAM_COUNT;	}	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->fetchFromBindCursor();		RETURN_LONG(r);	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindstring) {	zval **sqlrcur,**variable;	const char *r;	uint32_t rl;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->getOutputBindString((*variable)->value.str.val);		rl=cursor->getOutputBindLength((*variable)->value.str.val);		if (r) {			RETURN_STRINGL(const_cast<char *>(r),rl,1);		}	}	RETURN_NULL();}DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindblob) {	zval **sqlrcur,**variable;	const char *r;	uint32_t rl;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->getOutputBindBlob((*variable)->value.str.val);		rl=cursor->getOutputBindLength((*variable)->value.str.val);		if (r) {			RETURN_STRINGL(const_cast<char *>(r),rl,1);		}	}	RETURN_NULL();}DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindclob) {	zval **sqlrcur,**variable;	const char *r;	uint32_t rl;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->getOutputBindClob((*variable)->value.str.val);		rl=cursor->getOutputBindLength((*variable)->value.str.val);		if (r) {			RETURN_STRINGL(const_cast<char *>(r),rl,1);		}	}	RETURN_NULL();}DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindinteger) {	zval **sqlrcur,**variable;	int64_t r;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->getOutputBindInteger((*variable)->value.str.val);		RETURN_LONG(r);	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbinddouble) {	zval **sqlrcur,**variable;	double r;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->getOutputBindDouble((*variable)->value.str.val);		RETURN_DOUBLE(r);	}	RETURN_DOUBLE(0.0);}DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindlength) {	zval **sqlrcur,**variable;	uint32_t r;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (cursor) {		r=cursor->getOutputBindLength((*variable)->value.str.val);		RETURN_LONG(r);	}	RETURN_LONG(0);}DLEXPORT ZEND_FUNCTION(sqlrcur_getoutputbindcursor) {	zval **sqlrcur,**variable;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&variable) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(variable);	sqlrcursor *cursor=NULL;	ZEND_FETCH_RESOURCE(cursor,sqlrcursor *,sqlrcur,-1,"sqlrelay cursor",sqlrelay_cursor);	if (!cursor) {		RETURN_LONG(0);	}	sqlrcursor	*s=cursor->getOutputBindCursor((*variable)->value.str.val);	s->copyReferences();	ZEND_REGISTER_RESOURCE(return_value,s,sqlrelay_cursor);}DLEXPORT ZEND_FUNCTION(sqlrcur_opencachedresultset) {	zval **sqlrcur,**filename;	bool r;	if (ZEND_NUM_ARGS() != 2 || 		zend_get_parameters_ex(2,&sqlrcur,&filename) == FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_string_ex(filename);	sqlrcursor *cursor=NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -