Search code examples
phpmysqlclone

Cloning of resource getting by executing the query


Below is statement which executes my query and returns a resource.

$Result = mysql_query($Query);  

I want to get clone of $Result.

How can I get its clone?


Solution

  • What you got in $Result is not really a cloneable resource, but a reference to a cursor that points to a position in a result set (meaning if you copy it and advance in one copy, it'll have advanced in the other as well). Assuming you want to read the same query results twice without repeating the query, this post might help: How to reset mysql pointer back to the first row in PHP?