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

📄 mssql.c

📁 又一款WEB游戏原代码Bk_Sources_RPG?忠豢頦EB游戏原代码Bk_Sources_RPG
💻 C
📖 第 1 页 / 共 3 页
字号:
	convert_to_long(mssql_result_index);	result = (mssql_result *) php3_list_find(mssql_result_index->value.lval,&type);		if (type!=msSQL_GLOBAL(le_result)) {		php3_error(E_WARNING,"%d is not a MS SQL result index",mssql_result_index->value.lval);		RETURN_FALSE;	}		if (result->cur_row >= result->num_rows) {		RETURN_FALSE;	}		if (array_init(return_value)==FAILURE) {		RETURN_FALSE;	}		for (i=0; i<result->num_fields; i++) {		tmp = result->data[result->cur_row][i];		pval_copy_constructor(&tmp);		if (msSQL_GLOBAL(magic_quotes_runtime) && tmp.type == IS_STRING) {			tmp.value.str.val = _php3_addslashes(tmp.value.str.val,tmp.value.str.len,&tmp.value.str.len,1);		}		_php3_hash_index_update(return_value->value.ht, i, (void *) &tmp, sizeof(pval), (void **) &pvalue_ptr);		_php3_hash_pointer_update(return_value->value.ht, result->fields[i].name, strlen(result->fields[i].name)+1, pvalue_ptr);	}	result->cur_row++;}/* {{{ proto object mssql_fetch_object(int result)   Fetch row as object */void php3_mssql_fetch_object(INTERNAL_FUNCTION_PARAMETERS){	php3_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU);	if (return_value->type==IS_ARRAY) {		return_value->type=IS_OBJECT;	}}/* }}} *//* {{{ proto array mssql_fetch_array(int result)   Fetch row as array */void php3_mssql_fetch_array(INTERNAL_FUNCTION_PARAMETERS){	php3_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU);}/* }}} *//* {{{ proto bool mssql_data_seek(int result, int offset)   Move internal row pointer */void php3_mssql_data_seek(INTERNAL_FUNCTION_PARAMETERS){	pval *mssql_result_index,*offset;	int type,id;	mssql_result *result;	msSQL_TLS_VARS;	if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &mssql_result_index, &offset)==FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long(mssql_result_index);	id = mssql_result_index->value.lval;		result = (mssql_result *) php3_list_find(id,&type);	if (type!=msSQL_GLOBAL(le_result)) {		php3_error(E_WARNING,"%d is not a MS SQL result index",id);		RETURN_FALSE;	}	convert_to_long(offset);	if (offset->value.lval<0 || offset->value.lval>=result->num_rows) {		php3_error(E_WARNING,"MS SQL:  Bad row offset");		RETURN_FALSE;	}		result->cur_row = offset->value.lval;	RETURN_TRUE;}/* }}} */static char *php3_mssql_get_field_name(int type){	switch (type) {		case SQLBINARY:		case SQLVARBINARY:			return "blob";			break;		case SQLCHAR:		case SQLVARCHAR:			return "char";			break;		case SQLTEXT:			return "text";			break;		case SQLDATETIME:		case SQLDATETIM4:		case SQLDATETIMN:			return "datetime";			break;		case SQLDECIMAL:		case SQLFLT8:		case SQLFLTN:			return "real";			break;		case SQLINT1:		case SQLINT2:		case SQLINT4:		case SQLINTN:			return "int";			break;		case SQLNUMERIC:			return "numeric";			break;		case SQLMONEY:		case SQLMONEY4:		case SQLMONEYN:			return "money";			break;		case SQLBIT:			return "bit";			break;		case SQLIMAGE:			return "image";			break;		default:			return "unknown";			break;	}}/* {{{ proto object mssql_fetch_field(int result [, int offset])   Get field information */void php3_mssql_fetch_field(INTERNAL_FUNCTION_PARAMETERS){	pval *mssql_result_index,*offset;	int type,id,field_offset;	mssql_result *result;	msSQL_TLS_VARS;	switch (ARG_COUNT(ht)) {		case 1:			if (getParameters(ht, 1, &mssql_result_index)==FAILURE) {				RETURN_FALSE;			}			field_offset=-1;			break;		case 2:			if (getParameters(ht, 2, &mssql_result_index, &offset)==FAILURE) {				RETURN_FALSE;			}			convert_to_long(offset);			field_offset = offset->value.lval;			break;		default:			WRONG_PARAM_COUNT;			break;	}		convert_to_long(mssql_result_index);	id = mssql_result_index->value.lval;		result = (mssql_result *) php3_list_find(id,&type);	if (type!=msSQL_GLOBAL(le_result)) {		php3_error(E_WARNING,"%d is not a MS SQL result index",id);		RETURN_FALSE;	}		if (field_offset==-1) {		field_offset = result->cur_field;		result->cur_field++;	}		if (field_offset<0 || field_offset >= result->num_fields) {		if (ARG_COUNT(ht)==2) { /* field specified explicitly */			php3_error(E_WARNING,"MS SQL:  Bad column offset");		}		RETURN_FALSE;	}	if (object_init(return_value)==FAILURE) {		RETURN_FALSE;	}	add_property_string(return_value, "name",result->fields[field_offset].name, 1);	add_property_long(return_value, "max_length",result->fields[field_offset].max_length);	add_property_string(return_value, "column_source",result->fields[field_offset].column_source, 1);	add_property_long(return_value, "numeric", result->fields[field_offset].numeric);	add_property_string(return_value, "type", php3_mssql_get_field_name(result->fields[field_offset].type), 1);}/* }}} *//* {{{ proto int mssql_field_length(int result [, int offset])   Get the length of a field */void php3_mssql_field_length(INTERNAL_FUNCTION_PARAMETERS){	pval *mssql_result_index,*offset;	int type,id,field_offset;	mssql_result *result;	msSQL_TLS_VARS;	switch (ARG_COUNT(ht)) {		case 1:			if (getParameters(ht, 1, &mssql_result_index)==FAILURE) {				RETURN_FALSE;			}			field_offset=-1;			break;		case 2:			if (getParameters(ht, 2, &mssql_result_index, &offset)==FAILURE) {				RETURN_FALSE;			}			convert_to_long(offset);			field_offset = offset->value.lval;			break;		default:			WRONG_PARAM_COUNT;			break;	}		convert_to_long(mssql_result_index);	id = mssql_result_index->value.lval;		result = (mssql_result *) php3_list_find(id,&type);	if (type!=msSQL_GLOBAL(le_result)) {		php3_error(E_WARNING,"%d is not a MS SQL result index",id);		RETURN_FALSE;	}		if (field_offset==-1) {		field_offset = result->cur_field;		result->cur_field++;	}		if (field_offset<0 || field_offset >= result->num_fields) {		if (ARG_COUNT(ht)==2) { /* field specified explicitly */			php3_error(E_WARNING,"MS SQL:  Bad column offset");		}		RETURN_FALSE;	}	return_value->value.lval = result->fields[field_offset].max_length;	return_value->type = IS_LONG;}/* }}} *//* {{{ proto string mssql_field_name(int result [, int offset])   Get the name of a field */void php3_mssql_field_name(INTERNAL_FUNCTION_PARAMETERS){	pval *mssql_result_index,*offset;	int type,id,field_offset;	mssql_result *result;	msSQL_TLS_VARS;	switch (ARG_COUNT(ht)) {		case 1:			if (getParameters(ht, 1, &mssql_result_index)==FAILURE) {				RETURN_FALSE;			}			field_offset=-1;			break;		case 2:			if (getParameters(ht, 2, &mssql_result_index, &offset)==FAILURE) {				RETURN_FALSE;			}			convert_to_long(offset);			field_offset = offset->value.lval;			break;		default:			WRONG_PARAM_COUNT;			break;	}		convert_to_long(mssql_result_index);	id = mssql_result_index->value.lval;		result = (mssql_result *) php3_list_find(id,&type);	if (type!=msSQL_GLOBAL(le_result)) {		php3_error(E_WARNING,"%d is not a MS SQL result index",id);		RETURN_FALSE;	}		if (field_offset==-1) {		field_offset = result->cur_field;		result->cur_field++;	}		if (field_offset<0 || field_offset >= result->num_fields) {		if (ARG_COUNT(ht)==2) { /* field specified explicitly */			php3_error(E_WARNING,"MS SQL:  Bad column offset");		}		RETURN_FALSE;	}	return_value->value.str.val = estrdup(result->fields[field_offset].name);	return_value->value.str.len = strlen(result->fields[field_offset].name);	return_value->type = IS_STRING;}/* }}} *//* {{{ proto string mssql_field_type(int result [, int offset])   Get the type of a field */void php3_mssql_field_type(INTERNAL_FUNCTION_PARAMETERS){	pval *mssql_result_index,*offset;	int type,id,field_offset;	mssql_result *result;	msSQL_TLS_VARS;	switch (ARG_COUNT(ht)) {		case 1:			if (getParameters(ht, 1, &mssql_result_index)==FAILURE) {				RETURN_FALSE;			}			field_offset=-1;			break;		case 2:			if (getParameters(ht, 2, &mssql_result_index, &offset)==FAILURE) {				RETURN_FALSE;			}			convert_to_long(offset);			field_offset = offset->value.lval;			break;		default:			WRONG_PARAM_COUNT;			break;	}		convert_to_long(mssql_result_index);	id = mssql_result_index->value.lval;		result = (mssql_result *) php3_list_find(id,&type);	if (type!=msSQL_GLOBAL(le_result)) {		php3_error(E_WARNING,"%d is not a MS SQL result index",id);		RETURN_FALSE;	}		if (field_offset==-1) {		field_offset = result->cur_field;		result->cur_field++;	}		if (field_offset<0 || field_offset >= result->num_fields) {		if (ARG_COUNT(ht)==2) { /* field specified explicitly */			php3_error(E_WARNING,"MS SQL:  Bad column offset");		}		RETURN_FALSE;	}	return_value->value.str.val = estrdup(php3_mssql_get_field_name(result->fields[field_offset].type));	return_value->value.str.len = strlen(php3_mssql_get_field_name(result->fields[field_offset].type));	return_value->type = IS_STRING;}/* }}} *//* {{{ proto bool mssql_field_seek(int result, int offset)   Set field offset */void php3_mssql_field_seek(INTERNAL_FUNCTION_PARAMETERS){	pval *mssql_result_index,*offset;	int type,id,field_offset;	mssql_result *result;	msSQL_TLS_VARS;	if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &mssql_result_index, &offset)==FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long(mssql_result_index);	id = mssql_result_index->value.lval;		result = (mssql_result *) php3_list_find(id,&type);	if (type!=msSQL_GLOBAL(le_result)) {		php3_error(E_WARNING,"%d is not a MS SQL result index",id);		RETURN_FALSE;	}		convert_to_long(offset);	field_offset = offset->value.lval;		if (field_offset<0 || field_offset >= result->num_fields) {		php3_error(E_WARNING,"MS SQL:  Bad column offset");		RETURN_FALSE;	}	result->cur_field = field_offset;	RETURN_TRUE;}/* }}} *//* {{{ proto string mssql_result(int result, int row, mixed field)   Get result data */void php3_mssql_result(INTERNAL_FUNCTION_PARAMETERS){	pval *row, *field, *mssql_result_index;	int id,type,field_offset=0;	mssql_result *result;	msSQL_TLS_VARS;	if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &mssql_result_index, &row, &field)==FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(mssql_result_index);	id = mssql_result_index->value.lval;		result = (mssql_result *) php3_list_find(id,&type);	if (type!=msSQL_GLOBAL(le_result)) {		php3_error(E_WARNING,"%d is not a MS SQL result index",id);		RETURN_FALSE;	}		convert_to_long(row);	if (row->value.lval<0 || row->value.lval>=result->num_rows) {		php3_error(E_WARNING,"MS SQL:  Bad row offset (%d)",row->value.lval);		RETURN_FALSE;	}	switch(field->type) {		case IS_STRING: {			int i;			for (i=0; i<result->num_fields; i++) {				if (!strcasecmp(result->fields[i].name,field->value.str.val)) {					field_offset = i;					break;				}			}			if (i>=result->num_fields) { /* no match found */				php3_error(E_WARNING,"MS SQL:  %s field not found in result",field->value.str.val);				RETURN_FALSE;			}			break;		}		default:			convert_to_long(field);			field_offset = field->value.lval;			if (field_offset<0 || field_offset>=result->num_fields) {				php3_error(E_WARNING,"MS SQL:  Bad column offset specified");				RETURN_FALSE;			}			break;	}	*return_value = result->data[row->value.lval][field_offset];	pval_copy_constructor(return_value);}/* }}} */void php3_info_mssql(void){	char maxp[16],maxl[16];	msSQL_TLS_VARS;		if (msSQL_GLOBAL(max_persistent==-1)) {		strcpy(maxp,"Unlimited");	} else {		snprintf(maxp,15,"%ld",msSQL_GLOBAL(max_persistent));		maxp[15]=0;	}	if (msSQL_GLOBAL(max_links==-1)) {		strcpy(maxl,"Unlimited");	} else {		snprintf(maxl,15,"%ld",msSQL_GLOBAL(max_links));		maxl[15]=0;	}	php3_printf("<table cellpadding=5>"				"<tr><td>Allow persistent links:</td><td>%s</td></tr>\n"				"<tr><td>Persistent links:</td><td>%d/%s</td></tr>\n"				"<tr><td>Total links:</td><td>%d/%s</td></tr>\n"				"<tr><td>Application name:</td><td>%s</td></tr>\n"				"<tr><td valign=\"top\" width=\"20%%\">Client API information:</td><td><pre>%s</pre></td></tr>\n"				"</table>\n",				(msSQL_GLOBAL(allow_persistent)?"Yes":"No"),				msSQL_GLOBAL(num_persistent),maxp,				msSQL_GLOBAL(num_links),maxl,				msSQL_GLOBAL(appname),				"MSSQL 6.5");}/* {{{ proto void mssql_min_error_severity(int severity)   Sets the lower error severity */void php3_mssql_min_error_severity(INTERNAL_FUNCTION_PARAMETERS){	pval *severity;	msSQL_TLS_VARS;		if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &severity)==FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(severity);	msSQL_GLOBAL(min_error_severity) = severity->value.lval;}/* }}} *//* {{{ proto void mssql_min_message_severity(int severity)   Sets the lower message severity */void php3_mssql_min_message_severity(INTERNAL_FUNCTION_PARAMETERS){	pval *severity;	msSQL_TLS_VARS;		if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &severity)==FAILURE) {		WRONG_PARAM_COUNT;	}	convert_to_long(severity);	msSQL_GLOBAL(min_message_severity) = severity->value.lval;}/* }}} */#endif

⌨️ 快捷键说明

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