mysql_free_result

(PHP 4, PHP 5)

mysql_free_result질의결과를 메모리에서 해제

설명

bool mysql_free_result ( resource $result )

mysql_free_result()result 지시자와 관련된 점유 메모리를 해제한다.

mysql_free_result()는 결과 집합으로부터 질의에 사용되고 있는 메모리의 크기가 커서 문제가 발생할 수 있을 때 사용된다. 모든 연관된 결과 메모리는 스크립트 실행이 종료되면 메모리에서 자동적으로 해지된다.

인수

result

mysql_query() 호출을 통한 결과 resource.

반환값

성공 시 TRUE를, 실패 시 FALSE를 반환합니다.

result에 비-자원(non-resource) 변수가 사용이 되면, E_WARNING 등급의 에러가 발생될 것이다. 이것은 SELECT, SHOW, EXPLAIN, DESCRIBE 질의로 resource를 반환하는 mysql_query()만으로는 의미가 없다.

예제

Example #1 mysql_free_result() 예제

<?php
$result 
mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!
$result) {
    echo 
'Could not run query: ' mysql_error();
    exit;
}
/* Use the result, assuming we're done with it afterwords */
$row mysql_fetch_assoc($result);

/* Now we free up the result and continue on with our script */
mysql_free_result($result);

echo 
$row['id'];
echo 
$row['email'];
?>

주의

Note:

하위 호환을 위하여, 다음의 권장하지 않는 별칭을 사용할 수 있습니다: mysql_freeresult()

참고

add a note add a note

User Contributed Notes 3 notes

up
12
webmaster at bluesting dot co dot za
13 years ago
mysql_query() also returns a resource for "OPTIMIZE TABLE" statements!
up
12
admin at ifyouwantblood dot de
16 years ago
yes this function may increase the memory usage if you use unbuffered querys and if you have not fetched all the data from mysql. in this case the mysql api has a problem: you want to free the result but do not want to close the connection. now mysql will only accept another query if all data has been fetched, so the api now must fetch the rest of the data when calling mysql_free_result().

so only use unbuffered querys if you fetch all the data (and need it).
up
-30
Anonymous
17 years ago
If you're seeing warnings like "Warning: Unknown: 6 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0" and want to turn them off, set mysql.trace_mode = Off in your php.ini
To Top