class - PHP mysqli segmentation fault

343

im trying to extend the mysqli class in php in order to create a wrapper class. I would like this class to manage multiple connections.. I am currently at a very early stage and have hit a problem:

Auth Connected no: 1 1045:Access denied for user 'rootty'@'localhost' (using password: YES) Segmentation fault

It seems when the second connection has an error a segmentation fault is created however connection one errors correctly..

<?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;
   }
######Test script
#!/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";
770

Answer

Solution:

I would report this to the PHP/mysqli devs. A scripting language segfaulting is most likely an internal bug you cannot fix - while it might be possible to create a workaround the proper way is to get it fixed in the C code.

People are also looking for solutions to the problem: php - Google Analytics doesnt track any data

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.