10-20-2011, 09:35 AM
[eluser]Unknown[/eluser]
This Msdb Class will help you use MSSQL stored procedures with codeigniter.
Usage:
put this class in your application/library folder and load the class in the usual way:
in model or controller assign the result to a variable. Note the result is an array.
To select data use:
To execute any other query e.g. insert, update, delete...
Sample stored procedure:
use in your view to see the returned array
NOTE: When inserting or updating a field with data type TEXT in your table parse the parameter as shown:
Param1 here is of data type TEXT.
Hope this works for you. If you have any questions please comment to this thread.
Thanks,
@Email: [email protected], [email protected]
Download link: http://www.4shared.com/file/FIXtHIOB/Msdb.html
This Msdb Class will help you use MSSQL stored procedures with codeigniter.
Usage:
put this class in your application/library folder and load the class in the usual way:
Code:
$this->load->library('msdb');
in model or controller assign the result to a variable. Note the result is an array.
To select data use:
Code:
$result = $this->msdb->output('SP_Name', array('Param1'=>1, 'Param2'=>2), 'SELECT');
To execute any other query e.g. insert, update, delete...
Code:
$result = $this->msdb->output('SP_Name', array('Param1'=>1, 'Param2'=>2), 'EXECUTE');
Sample stored procedure:
Code:
Alter Procedure [dbo].[SP_Name]
@Param1 int, @Param2 varchar(500)
As
BEGIN
Select
*
From
Table_Name
Where FieldName1 = @Param1 And FieldName2 = @Param2
End
use
Code:
printf($result);
NOTE: When inserting or updating a field with data type TEXT in your table parse the parameter as shown:
Code:
$result = $this->msdb->output('SP_Name', array('Param1||'=>1, 'Param2'=>2), 'EXECUTE');
Param1 here is of data type TEXT.
Hope this works for you. If you have any questions please comment to this thread.
Thanks,
@Email: [email protected], [email protected]
Download link: http://www.4shared.com/file/FIXtHIOB/Msdb.html