I'm trying to create an object derived from the MySQLi object to easier handle database connections for my application. The thing is that I do not know how I shall be able to initalize the connection and keep it contained in the object. Let me illustrate what I mean:

   class db extend mysqli {
      //Overriding connect()
      public function connect($info){
          //This is where I get lost
          //I Want to be able to connect
          //without creating a new object
          //with mysqli_init()

          $mysqli = mysqli_init();

          //I want the connection to be
          //"attached" to $this object so that
          //the code would look something like...


          //But this I cannot do because of the
          //object that mysqli_init() returns which is
          //needed for mysqli_real_connect()

Any Ideas?

7 Years
Discussion Span
Last Post by gunnarflax

Thank you! I checked the manual earlier but couldn't find what I was looking for. Thanks!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.