Hi all,
I'm pretty new to FuelPHP and using it to create a small API for an internal database. However, I am having issues executing an MS SQL stored Procedure.
The code I am using is as follows...
$new_lead_id = \DB::query("DECLARE @NewLeadID int
EXEC ".static::$_leadpool_database.".dbo.isp_CreateNewClient_103 @Title = '".$title."', @Initials = '', @Forename = '".$forename."', @MiddleNames = '', @Surname = '".$surname."', @DateOfBirth = NULL, @Email = '', @MaritalStatus = '', @Gender = '', @StreetAndNumber = '".$address."', @Area = '".$area."', @District = '', @Town = '".$town."', @County = '', @Country = '', @Postcode = '".$postcode."', @ID = @NewLeadID OUTPUT
SELECT NewLeadID = @NewLeadID
", \DB::SELECT)->execute(static::$_connection);
When I run the query in Management Studio it executes with no problems and then returns the new lead ID with no issues. When I use the code above I don't get any response and the Stored Procedure doesn't execute at all. However no error messages are returned.
I'm quite confused.
Can anyone shed any light on the situation?
I will add, personally I'd much rather be working with MySQL, or even just standard queries but I'm forced to work using specific Stored Procedures due to the system I am interacting with.
Nothing looks out of the ordinary I don't think.
DECLARE @NewLeadID int EXEC LeadPool_Test.dbo.isp_CreateNewClient_103 @Title = 'Mr', @Initials = '', @Forename = 'Simon', @MiddleNames = '', @Surname = 'Skinner', @DateOfBirth = NULL, @Email = '', @MaritalStatus = '', @Gender = '', @StreetAndNumber = 'omitted', @Area = 'omitted', @District = '', @Town = 'omitted', @County = '', @Country = '', @Postcode = 'omitted', @ID = @NewLeadID OUTPUT SELECT NewLeadID = @NewLeadID
Speed: 33.012 ms
No errors shown at all, exactly the same as previous queries.
I have removed the actual address details when I pasted here. There are no issues with validation etc. Pasting the query the profiler outputs into SQL Management studio adds the details and returns the new LeadID as expected!
We don't have any Microsoft environment in the team, so it will be difficult for us to debug it.
The DB layer uses standard PDO calls to run MSSQL queries, perhaps you can debug the PDO driver yourself and see what the issue might be?