[Release] Sample Procedure callable by PHP & SQL
Tags blog, sample procedure, silkroad, tschulian, vsro
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
Call the Proc via PHP:
Call the Proc via SQL:
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
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' ");
}
{
return core::$sql -> getRow("exec sys_FreeStorageSlots '$userID' ");
}
Quote:
exec @lots = sys_FreeStorageSlots @D
Total Comments 0