<?php
$con= mysql_connect("localhost","root","mysql");
mysql_select_db("Db_name",$con);
$res=mysql_query("select *from table_name");
mysql_close($con); // closing connection before fetching contents.
while($r=mysql_fetch_array($res)) {
echo $r['ename'];
}
?>
This programs works even if i close the connection before fetching contents from the table.
In order get table contents from the $res connection is not necessary ?
Is$res just a program variable ? If so what kind of data structure it is using(associative array ? )
In oracle we have implicit cursor and explicit cursor. Are there any equivalent things in mysql?
In the above program where cursors come into picture ?
$resin your case is a special type called a “Resource”. Simply put it is a collection of the data returned which the mysql_fetch_* functions operate. As such, it can live beyond the connection. Check the documentation for more details.