Background Image
조회 수 24115 추천 수 67 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 수정 삭제
제가 저번에 php에서 프로시저 사용하는 것을 올렸는데요..
7.3 버전이 나오고 나서는 cubrid_prepare 함수가 추가되어서 저번과 같이 따로 변수를 선언하는 작업을 할 필요가 없어졌습니다.

그래서 다시 간단하게 나마 사용 방법을 올립니다.


[자바 소스 ,   Hello.java]

public class Hello {
        public static String sayHello(int i) {
                return "count : " + i;
        }
}

// javac Hello.java
// loadjava demodb Hello.class

[프로시저 등록 ]

1. hello_test , 일반 프로시저

   create function hello_test (i int) return string
   as language JAVA
   name ''''Hello.sayHello(int) RETURN java.lang.String'''';


[php 예제]

$con =  cubrid_connect(''''localhost'''',''''33000'''',''''demodb'''',''''dba'''','''''''');

// 예제 1. select

$sql = "select * from db_root where 1 < ? ";
$stmt = cubrid_prepare($con, $sql);

$search = 10;

cubrid_bind($stmt, 1, $search);

$result = cubrid_execute($stmt);

while($arr = cubrid_fetch($stmt)) {
        var_dump($arr);
}


// 예제 2. 프로시저 및 함수
$sql = "call hello_test(?)";
$stmt = cubrid_prepare($con, $sql);

$search = 10;

cubrid_bind($stmt, 1, $search);

$result = cubrid_execute($stmt);

while($arr = cubrid_fetch($stmt)) {
        var_dump($arr);
}


cubrid_disconnect($con);


추가로 설명을 드리면

일반적으로 select 에 대해서

$result = cubrid_execute($con, $sql);

cubrid_fetch($result);

execute의 결과인 리소를 사용하지만


cubrid_prepare를 쓰시게 되면

$req = cubrid_prepare($con, $sql);

cubrid_execute($con, $req);
cubrid_fetch($req);

와 같이 prepare로 저장해놨던 리소스를 그대로 사용합니다.

참고 하시면 좋을 듯 합니다.

* 아직 out 변수는 어떻게 사용하는지 모르겠네요.. 따로 방법이 있는지 궁금합니다.

  1. 큐브리드용 그누보드(GNUBOARD)4 공개

    Date2007.02.26 By한마루 Views1560623
    Read More
  2. CUBRID 2008 NBD Bench 시험 결과 보고서

    Date2008.12.09 Byadmin Views45684
    Read More
  3. APMSETUP 6: Apache+PHP+CUBRID를 한번의 실행으로......

    Date2009.06.02 By정병주 Views39152
    Read More
  4. 큐브리드용 그누보드 4.21.0

    Date2007.06.22 By한마루 Views38480
    Read More
  5. Windows 기반의 Apache + PHP + CUBRID를 한방에... APMSETUP 7 출시

    Date2010.01.05 By정병주 Views34892
    Read More
  6. 게시판 기능을 통해 본 오픈소스 DBMS 비교

    Date2009.06.27 Byadmin Views33087
    Read More
  7. HDD vs. SSD에서의 DBMS (CUBRID, MySQL) 성능 비교 자료

    Date2010.08.26 By정병주 Views32905
    Read More
  8. NHN DeView 2008 발표자료

    Date2008.12.07 By정병주 Views32671
    Read More
  9. NHN DeView 2008 동영상

    Date2008.12.07 By정병주 Views31543
    Read More
  10. JDBC sample 프로그램입니다

    Date2007.10.25 By관리자 Views30805
    Read More
  11. 울트라에디트 사용자를 위한 CUBRID 함수 구문강조 파일

    Date2009.07.03 By시난 Views30449
    Read More
  12. WordPress for CUBRID 2008

    Date2009.08.06 By정병주 Views29726
    Read More
  13. 알지보드 4.1.0 베타 다운로드

    Date2009.06.03 By정병주 Views27402
    Read More
  14. 그누보드 4.31.08 (CUBRID) 공개

    Date2009.07.01 By시난 Views27237
    Read More
  15. 소프트웨어 개발 프로세스 자료들...

    Date2007.01.17 By관리자 Views26812
    Read More
  16. NBench를 이용하여 게시판 Benchmark 해보기

    Date2009.01.07 By정병주 Views26476
    Read More
  17. Autoset 4.3.2

    Date2009.03.11 ByPrototype Views25542
    Read More
  18. CUBRID 지원 텍스트큐브(Textcube) 다운로드

    Date2009.07.01 By정병주 Views25024
    Read More
  19. CUBRID 매니저 아이콘 디자인 자료

    Date2009.05.15 By정병주 Views24649
    Read More
  20. php로 cubrid 프로시저 사용하기 2 - cubrid_prepare 이용 -

    Date2007.10.30 By박진호 Views24115
    Read More
Board Pagination Prev 1 2 3 4 Next
/ 4

Contact Cubrid

대표전화 070-4077-2110 / 기술문의 070-4077-2113 / 영업문의 070-4077-2112 / Email. contact_at_cubrid.com
Contact Sales