공지

레이블이 php인 게시물을 표시합니다. 모든 게시물 표시
레이블이 php인 게시물을 표시합니다. 모든 게시물 표시

2006년 9월 14일 목요일

[펌] php final 메소드 register_shutdown_function

As Andrew states below, it's IMPERATIVE that you use the imagedestroy() function. But your script may abort before it reaches the call to imagedestroy() (for example the user may click the browsers 'stop' button). In this case the default PHP behaviour is to abort the script, never reaching your call to imagedestroy().
One way of doing it (the one which works very well for me) is with register_shutdown_function():


<?
function shutdown_func() {
global $img;
if($img)
imagedestroy($img);
}
register_shutdown_function("shutdown_func");
$img = imagecreate...(...);
... // manipulate image
// normally I'd need the following line, but now it's handled by shutdown_func()
// imagedestroy($img);
?>


2006년 8월 30일 수요일

php 4.X 버전에서 멀티 쿼리 쓰기

요구 조건 :
mysql server 4.1. 이상
libmysqlclient 버전 3306 이상
php-devel ( centos 나 redhat은 yum으로 깔끔하게 설치 가능)

방법 1
1)  기존 php-mysql은 대부분 함께 제공 되는 낮은버전의 libmysqlclient 를 쓰므로 최신 libmysqlclient로 다시 컴파일 하여 재설치( php-devel 필요)
2) 디비컨넥션 맻을시
          mysql_connect(server, user, passward , false , 65536 );

해당 컨넥션에서 멀티 쿼리가 가능하다.
           ex) $result = mysql_query( " select * from temp ; select * from temp2;");

단 이 경우는 php-mysql 에서 result_set 에 대한 메모리 처리를 안하므로 위와 같은 경우는
첫번째 쿼리의 result_Set에만 접근 가능하고 나머지 result_set은 메모리 누수 발생.....

그러므로
       ex) $result = mysql_query("
             insert something;
             update something;"
              );
등과 같이 result set이 없는 쿼리문만 사용 할 수 있음

방법 2
직접 php-mysql 확장을 수정 여타 result_set을 다룰 수 있는 모듈 작성
-- 멀티 result_set 지원은 따로 해줘야 할게 너무 많아서 GG

PS mysql 4.1 버전이상 innoDB를 사용 할 경우 transaction 도 사용할 수 있다.

     $result = mysql_query("
        start transaction ;
        insert something ~~;
        insert something2 ~~;
       commit;
     );

MYSQL PHP 꽁짜라고 우습게 볼게 아니더라...

관련 자료들
http://dev.mysql.com/doc/refman/4.1/en/c-api-multiple-queries.html mysql
http://kr2.php.net/manual/kr/zend.php  php 확장 모듈 및 코어 확장 자료

2006년 7월 17일 월요일

IDC 에 대한 ... 글

언제나 나에겐 IDC는 미지의 공간이었다... 머하는 델가...


http://kldp.org/node/71097


이런데였다.. ㅋㅋ


ps... : 일반인들은 개발자가 어떤일을 하는지 잘 모른다... 역시 개발자도 .. IDC(시스템 엔지니어...?) 가 머하는지 잘 모르는 듯 ㅎㅎ