Welcome Guest, Not a member yet? Register   Sign In
Using MSSQL stored procedures with codeigniter
#1

[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:
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);
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:
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: noadek@yahoo.co.uk, [email protected]

Download link: http://www.4shared.com/file/FIXtHIOB/Msdb.html


Messages In This Thread
Using MSSQL stored procedures with codeigniter - by El Forum - 10-20-2011, 09:35 AM
Using MSSQL stored procedures with codeigniter - by El Forum - 06-06-2013, 09:10 AM
Using MSSQL stored procedures with codeigniter - by El Forum - 06-06-2013, 02:55 PM
Using MSSQL stored procedures with codeigniter - by El Forum - 06-27-2013, 03:24 AM
Using MSSQL stored procedures with codeigniter - by El Forum - 07-10-2014, 08:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB