Register for your free account! | Forgot your password?

Go Back   elitepvpers > Blogs > tschulian
You last visited: Today at 00:57

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Rate this Entry

[Release] Sample Procedure callable by PHP & SQL

Posted 05/27/2016 at 12:08 by tschulian
Updated 05/27/2016 at 12:37 by tschulian

Hello,
since I had some trouble to call the same SQL-Procedure via PHP AND via SQL here is small Sample which shows how I solved that nasty issue.

EDIT: SINCE THAT AUTO PARSE FUNCTION DESTROYS EVERYTHING I replaced CODE tags with QUOTE and added pastebin containers: @ would be cool to fix this issue asap...

Whole Procedure


SQL and PHP CALL




Quote:
USE [SRO_VT_CUSTOM]
GO
/****** Object: StoredProcedure [dbo].[sys_FreeStorageSlots] Script Date: 5/27/2016 11:31:51 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[sys_FreeStorageSlots]
-- =============================================
-- Author: <tschulian>
-- Create date: <27.05.2016>
-- Description: <Returns the free Storage Slots of the selected User>
-- =============================================
-- START Callparamters
@struserID varchar(max)
-- END Callparamters

AS
BEGIN SET NOCOUNT ON;

declare
@curJID int,
@curStorage int,
@maxstorage int,
@torage int


set @curJID = (select JID from SRO_VT_ACCOUNT..TB_User where StrUserID = @struserID);
set @maxstorage = (select ChestSize from SRO_VT_SHARD.._ChestInfo where JID = @curJID);
set @curStorage = (SELECT count(ItemID) FROM SRO_VT_SHARD.._Chest where UserJID = @curJID and (ItemID != 0 and ItemID is not NULL))
set @torage = @maxstorage - @curStorage;

END

BEGIN TRANSACTION

select @torage; -- PHP uses this to work properly!
return @torage; -- SQL uses this to work properly!

COMMIT TRANSACTION

Call the Proc via PHP:
Quote:
public static function freeStorage($userID)
{
return core::$sql -> getRow("exec sys_FreeStorageSlots '$userID' ");
}
Call the Proc via SQL:
Quote:
exec @lots = sys_FreeStorageSlots @D
Views 1342 Comments 0 Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 

All times are GMT +2. The time now is 00:57.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.