Results 1 to 2 of 2

Thread: Question: Closing mysqli connection

      
  1. #1
    Member Jolo Balbin's Avatar
    Join Date
    Jan 2012
    Posts
    90

    Question: Closing mysqli connection

    PHP Code:
    function pathFind(/*parameters*/)
    {
      
    $db = new DB();
      
    $dbq $db->DBcon();

      
    // query here.

      
    $stmt $dbq->prepare($query);
      
    $stmt->bind_param(/*parameters*/);
      
    $stmt->execute();
      
    $stmt->bind_result(/*parameters*/);

      while(
    $stmt->fetch())
      {
        
    pathFind(/*variables*/); <----- recursion here.
      }

    So here. Do I still need to close my connections even PHP can do it for me? I'm just worried that I exceed the connection limit because my function is in recursion.

    And when I attempt to close, I receive a warning: Couldn't fetch mysqli.

  2. #2
    Member YowMamaSita's Avatar
    Join Date
    Feb 2012
    Posts
    63
    when the interpreter finishes reading the a php file, all connections made are automatically closed. pero in cases na this is used inside recursions, until matapos yung recursion, di siya magcloclose so its best if you do close it before the function ends

    with the warning, try replacing mysqli:// with mysql:// or kung wala kang ganyang strings, it has something to do with your settings on how php connects to mysql

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •