Mysql to y_ini
#2

okay that's too long just this plz
Код:
stock LoadProperty(Houseid)
{
	new string[256] ,query[300];


    	format(query, sizeof(query), "SELECT * FROM lshousedata WHERE Houseid = '%d'", Houseid);
		//We only select the variables that we want to use.
		mysql_query(query); //Queries the result
		mysql_store_result(); //Store a result because it's a SELECT statement.

		if(mysql_num_rows() > 0) //If the houseid is found
		{

			while(mysql_retrieve_row()) //it will be running until there are no more rows to be retrieved
			{

			mysql_fetch_field_row(string, "OwnerName");
			strmid(HouseData[Houseid][h_OwnerName], string, 0, strlen(string), 256);
			//HouseInfo[Houseid][h_OwnerName] = strval(string);

			mysql_fetch_field_row(string, "OwnerID");
			HouseData[Houseid][h_OwnerID] = strval(string);

			mysql_fetch_field_row(string, "RenterName");
			strmid(HouseData[Houseid][h_RenterName], string, 0, strlen(string), 256);
			//HouseInfo[Houseid][h_RenterName] = strval(string);

			mysql_fetch_field_row(string, "RenterID");
			HouseData[Houseid][h_RenterID] = strval(string);

			mysql_fetch_field_row(string, "HouseName");
			strmid(HouseInfo[Houseid][h_HouseIntName], string, 0, strlen(string), 256);
			//HouseInfo[Houseid][h_HouseName] = strval(string);

			mysql_fetch_field_row(string, "Value");
			HouseData[Houseid][h_Value] = strval(string);

			mysql_fetch_field_row(string, "Rent");
			HouseData[Houseid][h_Rent] = strval(string);

			mysql_fetch_field_row(string, "ForSale");
			HouseData[Houseid][h_ForSale] = strval(string);

			mysql_fetch_field_row(string, "Alarm");
			HouseData[Houseid][h_Alarm] = strval(string);

			mysql_fetch_field_row(string, "Lock");
			HouseData[Houseid][h_Lock] = strval(string);

			mysql_fetch_field_row(string, "Money");
			HouseData[Houseid][h_Money] = strval(string);

			mysql_fetch_field_row(string, "Drugs");
			HouseData[Houseid][h_Drugs] = strval(string);

			mysql_fetch_field_row(string, "Condoms");
			HouseData[Houseid][h_Condoms] = strval(string);

			mysql_fetch_field_row(string, "Flowers");
			HouseData[Houseid][h_Flowers] = strval(string);

			mysql_fetch_field_row(string, "Robberies");
			HouseData[Houseid][h_Robberies] = strval(string);

			mysql_fetch_field_row(string, "Breakins");
			HouseData[Houseid][h_Breakins] = strval(string);

			mysql_fetch_field_row(string, "OwnerVisits");
			HouseData[Houseid][h_OwnerVisits] = strval(string);

			mysql_fetch_field_row(string, "OtherVisits");
			HouseData[Houseid][h_OtherVisits] = strval(string);

			mysql_fetch_field_row(string, "Purchasers");
			HouseData[Houseid][h_Purchasers] = strval(string);

			mysql_fetch_field_row(string, "Rented");
			HouseData[Houseid][h_Rented] = strval(string);
			}

  		}
	mysql_free_result(); //We must always free a stored result
	return 1;
}
//==============================================================================
stock SaveProperty(Houseid)
{
	new query[300];
		format(query, sizeof(query), "SELECT * FROM lshousedata WHERE Houseid = '%d'", Houseid);
		mysql_query(query); //Queries the result
		mysql_store_result(); //Store a result because it's a SELECT statement.

		if(mysql_num_rows() == 0) //If the houseid is not found
		{

		if (CREATE_PLAYER_DATABASE == 1)
		{

		format(query, sizeof(query), "INSERT INTO lshousedata (Houseid) VALUES ('%d')",Houseid); //Insert string
		mysql_query(query);

		}else{

		mysql_query("ALTER TABLE lshousedata ADD OwnerName VARCHAR(128) NOT NULL default 'The Bank'");
		mysql_query("ALTER TABLE lshousedata ADD OwnerID INT(11) NOT NULL default -1");
		mysql_query("ALTER TABLE lshousedata ADD RenterName VARCHAR(128) NOT NULL default 'None'");
		mysql_query("ALTER TABLE lshousedata ADD RenterID INT(11) NOT NULL default -1");
		mysql_query("ALTER TABLE lshousedata ADD HouseName VARCHAR(128) NOT NULL default 'House'");
		mysql_query("ALTER TABLE lshousedata ADD Value INT(11) NOT NULL default 200000");
		mysql_query("ALTER TABLE lshousedata ADD Rent INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD ForSale INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Alarm INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Lock INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Money INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Drugs INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Condoms INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Flowers INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Robberies INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Breakins INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD OwnerVisits INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD OtherVisits INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Purchasers INT(11) NOT NULL default 0");
		mysql_query("ALTER TABLE lshousedata ADD Rented INT(11) NOT NULL default 0");

		}


		}else{


		format(query, sizeof(query), "UPDATE lshousedata SET OwnerName = '%s' WHERE Houseid = '%d'",HouseData[Houseid][h_OwnerName],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET OwnerID = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_OwnerID],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET RenterName = '%s' WHERE Houseid = '%d'",HouseData[Houseid][h_RenterName],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET RenterID = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_RenterID],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET HouseName = '%s' WHERE Houseid = '%s'",HouseInfo[Houseid][h_HouseIntName],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Value = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Value],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Rent = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Rent],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET ForSale = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_ForSale],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Alarm = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Alarm],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Lock = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Lock],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Money = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Money],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Drugs = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Drugs],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Condoms = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Condoms],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Flowers = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Flowers],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Robberies = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Robberies],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Breakins = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Breakins],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET OwnerVisits = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_OwnerVisits],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET OtherVisits = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_OtherVisits],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Purchasers = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Purchasers],Houseid);
		mysql_query(query);

		format(query, sizeof(query), "UPDATE lshousedata SET Rented = '%d' WHERE Houseid = '%d'",HouseData[Houseid][h_Rented],Houseid);
		mysql_query(query);

		}

	mysql_free_result(); //Frees the result

	return 1;
}
Reply


Messages In This Thread
Mysql to y_ini - by AroseKhanNiazi - 21.04.2014, 16:21
Re: Mysql to y_ini - by AroseKhanNiazi - 21.04.2014, 17:14
Re: Mysql to y_ini - by gtakillerIV - 21.04.2014, 17:18
Re: Mysql to y_ini - by AroseKhanNiazi - 21.04.2014, 17:28
Re: Mysql to y_ini - by Baltazar - 21.04.2014, 19:22
Re: Mysql to y_ini - by AroseKhanNiazi - 22.04.2014, 08:06

Forum Jump:


Users browsing this thread: 1 Guest(s)