PHP mysqli分段错误

时间:2010-11-01 14:01:13

标签: php class connection mysqli segmentation-fault

我试图在php中扩展mysqli类以创建一个包装类。我希望这个课程能够管理多个连接。我目前处于一个非常早期的阶段并遇到了问题:

Auth Connected no:1 1045:用户'rootty'@'localhost'拒绝访问(使用密码:YES) 分段错误

当第二个连接出现错误时,似乎会创建分段错误,但是连接错误正确..

<?php

class mysqli_ls extends mysqli
{
   private $link    = array();
   private $link_no = 0;


/* ************************************************************ */

   public function __construct()
   {
   }

/* ************************************************************ */

   public function open($host='', $user='', $pass='', $port='3306', $database='')
   { 
      if ( empty($host) || empty($user) || empty($pass) || empty($database) ) 
      {
         $this->error[] = "Missing required connection variables";
         return false;
      } 

      $this->link_no++;
      @$this->link[ $linkno ] = $this->connect($host, $user, $pass, $database, $port);



        if ($this->connect_errno)

        {

         $this->error[] = $this->connect_errno .':'. $this->connect_error;
         return false;

        }

      return $this->link_no;
   }
######测试脚本
#!/usr/bin/php
<?php

require_once('mysqli.class.php');
$_mysqli = new mysqli_ls;

$_auth = $_mysqli->open('localhost','root','xx','3306','auth');
if ($_auth === false)  print $_mysqli->get_last_error() ."\n";
else print 'Auth Connected no: '. $_auth ."\n";

$_trak = $_mysqli->open('localhost','root','sxx','3306','wlr_tracker');
if ($_trak === false)  print $_mysqli->get_last_error() ."\n";
else print 'Trak Connected no: '. $_trak ."\n";

1 个答案:

答案 0 :(得分:0)

我会将此报告给PHP / mysqli开发人员。脚本语言segfaulting很可能是一个你无法解决的内部错误 - 虽然可能以正确的方式创建一个解决方法是在C代码中修复它。