Page 1 of 1

using mysqli as an extended class

Posted: Sat Nov 11, 2006 10:42 am
by mbaroz
HI There
I want to start using mysqli method to connect to my db . so far i had a complete class to use with mysql functions.

I tried to wrap the mysqli object as a custom class that query , return the rows as an array and so on.. but couldnt get a working one.

I need a class that use mysqli functions to connect, query , return rows array , and at the end closes the connection .

if anyone can help it would be Great
Thanks
Moshe

Posted: Sat Nov 11, 2006 10:46 am
by feyd
What have you tried thus far?

using mysqli as an extended class

Posted: Sat Nov 11, 2006 11:05 am
by mbaroz
HI
i tried to create a class:

Code: Select all

class db{
function db($host,$user,$pass,$dbname) {
$con=new mysqli(.....)
function GetRows() {
}
i dont know how to create the method of returning rows.

thats what i need help in .

Posted: Sat Nov 11, 2006 11:13 am
by feyd
If your class is going to contain an object of mysqli, then you will need to set a property of the class to an instance of the object so other methods can access it.

The basic concept is thus

Code: Select all

class foo
{
  var $my = null;
  function foo(..)
  {
    $this->my = new mysqli(..);
  }

  function bar(..)
  {
    return $this->my->someFunction();
  }
}

using mysqli as an extended class

Posted: Sat Nov 11, 2006 11:17 am
by mbaroz
Ok great ,
But what about the query / rows fetching method ? how it will work ?

Posted: Sat Nov 11, 2006 11:29 am
by feyd
it's the same concept throughout.