php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69635 PHP version 5.6.7 - Issue while reconnect usign mysqli
Submitted: 2015-05-14 10:12 UTC Modified: 2015-05-24 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nikunj dot vasani at flydocs dot aero Assigned: cmb (profile)
Status: No Feedback Package: mysql (PECL)
PHP Version: 5.6.8 OS: Windows Server 2012
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
4 + 17 = ?
Subscribe to this entry?

 
 [2015-05-14 10:12 UTC] nikunj dot vasani at flydocs dot aero
Description:
------------
class DB
{
  var $Link_ID  = 0;
  var $Host     = "";
  var $Database = "";
  var $User     = "";
  var $Password = "";

  function DB_Sql($DBArray) 
  {
      $this->connect($DBArray);
  }
  function connect($DBArray) 
  {
	$this->Link_ID=0;
  	if($DBArray!=NULL)
	{
		$this->Database=$DBArray["DATABASE"];
		$this->Host=$DBArray["HOST"];
		$this->User=$DBArray["USER"];
		$this->Password=$DBArray["PASSWORD"];
	}
    if ( 0 == $this->Link_ID )
	 {
     	 $this->Link_ID=mysqli_connect($this->Host, $this->User, $this->Password);
		  if (!$this->Link_ID) {
			
			$this->halt("connect($Host, $User, \$Password) failed.");
			return 0;
		  }

      if (!@mysqli_select_db($this->Link_ID,$this->Database)) {
        
		$this->halt("cannot use database ".$this->Database);
        return 0;
      }
    }
    
    return $this->Link_ID;
  }
   function query($Query_String,$where=NULL) 
  {
    if ($Query_String == "")      
      return 0;
	  if(!$this->Link_ID)
	  {
		if($this->type == "mysql")
		{
			if (!$this->connect()) {
			  return 0; /* we already complained in connect() about that. */
			};
		}
	  }
    if ($this->Query_ID) {
      @mysqli_stmt_free_result($this->Query_ID);
    }
	$strType='';
	$this->Query_ID=mysqli_prepare($this->Link_ID,$Query_String) ;
	call_user_func_array('mysqli_stmt_bind_param', array_merge (array($this->Query_ID, $strType), $this->refValues($where))) ; 
	}	
	mysqli_stmt_execute($this->Query_ID) ; 
	
      # Will return nada if it fails. That's fine.
      return $this->Query_ID;
  }
}

Test script:
---------------
$db  = new DB($DBArray);
$db->query("select * from xyz");  // This is working fine.

$db->Link_ID=0;
$db->query("select * from abc");  // This is not working. I can not get any value of the column. 

Please Note : above code is already working fine in 5.4.
By Testing we found that after remove @mysqli_stmt_free_result($this->Query_ID); line from free function, code is running properly.But for not all the sections.

Please advice on this asap
Thnaks





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-14 10:47 UTC] nikunj dot vasani at flydocs dot aero
Do we need to check in PHP.ini or in my.ini for this issue?
 [2015-05-15 07:23 UTC] nikunj dot vasani at flydocs dot aero
hello
By testing i find that  @mysqli_stmt_free_result() is not working in PHP version 5.6.7.
As i removed  @mysqli_stmt_free_result() from my code, it is working fine as it worked earlier.
But is it good to remove this code? 
Is there anything that i can do wrong in the code?
Thanks
 [2015-05-15 20:44 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2015-05-15 20:44 UTC] cmb@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.
 [2015-05-24 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC