sqldata/sqldata.cpp
// Drop foreign keys defined on selected tables in the target database
Drop foreign keys defined on selected tables in the target database
Drop foreign keys defined on selected tables in the target database
int SqlData::DropReferences(int *all_keys, size_t *time_spent)
{
	if(_tables == NULL)
		return -1;
	size_t start = (time_spent != NULL) ? Os::GetTickCount() : 0;
	int all = 0;
	for(std::list<std::string>::iterator i = _tables->begin(); i != _tables->end(); i++)
	{
		std::string t_table;
		int keys = 0;
		size_t time_s = 0;
		MapObjectName((*i), t_table);
		_db.DropReferences(SQLDB_TARGET_ONLY, t_table.c_str(), &time_s, &keys);
		if(keys > 0)
		{
			SqlDataReply reply;
			reply._cmd = _command;
			reply._cmd_subtype = SQLDATA_CMD_DROP_FOREIGN_KEY;
			reply._time_spent = time_s;
			reply._int1 = keys;
			strcpy(reply._s_name, (*i).c_str());
			strcpy(reply._t_name, t_table.c_str());
			if(_callback != NULL)
				_callback(_callback_object, &reply);
		}
		all += keys;
	}
	if(all_keys != NULL)
		*all_keys = all;
	if(time_spent != NULL)
		*time_spent = Os::GetTickCount() - start;
	return 0;
}
int SqlData :: DropReferences ( int * all_keys , size_t * time_spent ) { if ( _tables == NULL ) return -1 ; size_t start = ( time_spent != NULL ) ? Os :: GetTickCount ( ) : 0 ; int all = 0 ; for ( std :: list < std :: string > :: iterator i = _tables -> begin ( ) ; i != _tables -> end ( ) ; i ++ ) { std :: string t_table ; int keys = 0 ; size_t time_s = 0 ; MapObjectName ( ( * i ) , t_table ) ; _db . DropReferences ( SQLDB_TARGET_ONLY , t_table . c_str ( ) , & time_s , & keys ) ; if ( keys > 0 ) { SqlDataReply reply ; reply . _cmd = _command ; reply . _cmd_subtype = SQLDATA_CMD_DROP_FOREIGN_KEY ; reply . _time_spent = time_s ; reply . _int1 = keys ; strcpy ( reply . _s_name , ( * i ) . c_str ( ) ) ; strcpy ( reply . _t_name , t_table . c_str ( ) ) ; if ( _callback != NULL ) _callback ( _callback_object , & reply ) ; } all += keys ; } if ( all_keys != NULL ) * all_keys = all ; if ( time_spent != NULL ) * time_spent = Os :: GetTickCount ( ) - start ; return 0 ; }
Drop foreign keys defined on selected tables in the target database
Drop foreign keys defined on selected tables in the target database
// Get the target name // Foreign key exist on this table