memory leak in php script

后端 未结 6 754
盖世英雄少女心
盖世英雄少女心 2021-01-13 14:39

I have a php script that runs a mysql query, then loops the result, and in that loop also runs several queries:

    $sqlstr = \"SELECT * FROM user_pred WHERE         


        
6条回答
  •  余生分开走
    2021-01-13 14:56

    I think you should try calling mysql_free_result() at some point during the loop. — From the comments:

    It's worth noting that mysql_query() only returns a resource for SELECT, SHOW, EXPLAIN, and DESCRIBE queries.

    So there is no result to free for an update query.

    Anyway, your approach is not the best to begin with. Try mysqli paramterized statements instead, or (even better) updating the rows at the database directly. It looks like all of the SQL in the loop could be handled with one single UPDATE statement.

提交回复
热议问题