I have this array
$REV = Array
(
0 => 240,
1 => 241,
2 => 242,
3 => 243,
4 => 249
);
and i'm using this code bellow to insert for now, stored each array's element in a row with $id, $userID, Type and Date
if (!empty($REV)) {
foreach ($REV as $val_rev) {
$values_rev[] = "('" . $ID . "','REV','" . $val_rev . "','" . $IDUSER . "',GETDATE())";
}
$values_rev_insert = implode(',', $values_rev);
$query_rev = "insert into dbo.CCLine (ID,CCType,CSID,IdUSer,DateCreated)values" . $values_rev_insert;
mssql_query($query_rev);
}
But what i want is can use this stored procedure but i dont have idea how to make to insert in one time using the sp:
$stmt = mssql_init('sp_insertRev');
mssql_bind($stmt, '@ID', $ID, SQLINT4);
mssql_bind($stmt, '@CCType', 'REV', SQLVARCHAR);
The array does not work here
mssql_bind($stmt, '@CSID', $val_rev, SQLINT4);//An example
mssql_bind($stmt, '@IdUSer', $IDUSER, SQLCHAR);
$result = mssql_execute($stmt);
How can i use this SP with the array
CREATE PROCEDURE [dbo].[sp_HCCInsert]
@ID int
,@CCType varchar(10)
,@CSID varchar(10)
,@IdUSer char(15)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @CCID as INT
INSERT INTO [dbo].[CCLine]
([ID]
,[CCType]
,[CSID]
,[IdUSer]
,[DateCreated])
VALUES
(@ID
,@CCType
,@CSID
,@IdUSer
,GETDATE())
SET @CCID = @@IDENTITY
Select @CCID as CCID
END