It's simple:

$row = mysql_query($sql, $this->connection); 

Now in $ row there will be something like "Resource id # 56". And now I need to save this object to a file. Without using " mysql_fetch_array ", etc. So that I could later retrieve this query result from the file and feed it to the functions " mysql_fetch_array ".

  • @MatthewP, maybe you explain a little why you need it? - Nofate
  • terantul, correctly understood. There is a class for working with DB, and I want to hook into one of the methods where the request itself takes place. This method returns "Resource id #", other methods such as "loadResult" already handle the result. So I want to interrogate the request and cache, and then get it from the cache if there is one. - MatthewP

2 answers 2

The CU wants to invent caching to reduce the number of calls to the database. As far as I know the pointers themselves can not be saved, but you can save to the file the result in an array. there is useful information

  • Thanks for the article, but I understand perfectly what I want to write and how to do it. The only question is, what would each method rewrite a bit of functionality, or to one, but as you said, it’s not possible to save what I want ( - MatthewP

No, but you can serialize the data itself (pure caching) or raise a persistent connection . However, I strongly recommend that you switch to mysqli, if not PDO.