MSSQL 프로시져 호출 > php

본문 바로가기
사이트 내 전체검색

php

MSSQL 프로시져 호출

페이지 정보

작성자 서방님 댓글 0건 조회 123회 작성일 12-04-18 14:59

본문

function next_row()
{
   $assoc =  mssql_fetch_assoc($this->result) ;

   return $assoc ;
}

/******************************************
   DESC : 프로시져 호출 선행자
   PRAM : MS-SQL에서 호출할 PROC NAME
   AUTH : DEV.LEE
==========================================*/
function strCallProc($procName)
{
   $this->stmt = mssql_init($procName, $this->con) ;
}

/***************************************
   DESC : 프로시져 호출 파라미터 설정
   PRAM :
       1 : proc 파람변수 , 2 : 입력할 data, 3 : 데이터 타입,
       4 : 아웃풋 파라미터 여부 (output 일경우 true)
       5 : null 가능 여부
       6 : 데이터 타입 길이
   AUTH : DEV.LEE

   <PARAM TYPE LIST>
   - SQLVARCHAR for binary
   - SQLINT4           for datetime
   - SQLFLT8           for decimal
   - SQLVARCHAR for image
   - SQLFLT8           for money
   - SQLCHAR           for nchar
   - SQLTEXT           for ntext
   - SQLFLT8           for numeric
   - SQLVARCHAR for nvarchar
   - SQLFLT8           for real
   - SQLINT4           for smalldatetime
   - SQLFLT8           for smallmoney
   - SQLVARCHAR for sql_variant
   - SQLINT4           for timestamp
   - SQLVARCHAR for varbinary
==========================================*/
function setParams($prcParam, $data, $type, $is_output = false, $is_null = false, $maxLen )
{
   mssql_bind($this->stmt, $prcParam, $data, $type, $is_output,  $is_null, $maxLen );
}

/******************************************
   DESC : 프로시져 호출 AND NO RECORDSET
   PRAM :
   AUTH : DEV.LEE
==========================================*/
function ExecSP()
{
   $this->result = mssql_execute($this->stmt) or die(mssql_get_last_message()); ;
   mssql_free_statement($this->stmt);
   $this->close() ;
}

/******************************************
   DESC : 프로시져 호출 AND RETURN RECORDSET
   PRAM :
   AUTH : DEV.LEE
==========================================*/
function ExecSPReturnRS()
{

   $this->result = mssql_execute($this->stmt) or die(mssql_get_last_message()); ;
   mssql_free_statement($this->stmt);

   $arrResult = Array() ;

   $i = 0 ;

   while($row = $this->next_row()){
       $arrResult[$i] = $row ;
       $i ++ ;
   }

   $this->close() ;
   return $arrResult ;

}

 


<호출 예제>

 

 

function getListOfMenuList()
{
   $this->strCallProc("uspA_GetAdminMenuList")  ;

   $this->setParams("@adminNumber", 1, SQLINT4, false, false, 8) ;

   $ret = $this->ExecSPReturnRS() ; // list 리턴

   return $ret ;
}

function login()
{
   $this->strCallProc("uspA_LoginAdmin")  ;

   $this->setParams("@adminID",   adminID, SQLVARCHAR, false, false, 32) ;
   $this->setParams("@adminPWD",  adminPWD, SQLVARCHAR, false, false, 16) ;
   $this->setParams("@adminNumber", &$adminNumber, SQLINT4, true, false, 8) ;

   $this->ExecSP() ;


   echo "adminNuimber : " . $adminNumber ;       // output 값

}

 


 

댓글목록

등록된 댓글이 없습니다.

Total 614건 34 페이지
게시물 검색

회원로그인

접속자집계

오늘
106
어제
190
최대
1,347
전체
167,514
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.