My database class extends MySQLi The following is a small class I extended MySQLi with.  I'm going to use this in my upcoming projects, but my main reason to do this class is learning, so I would like to submit this for your review, tell me if there are any bugs or improvements to be made.

NOTES:


I know about prepared statements, but I am not going to only run the same queries with different parameters, I'm expecting very different queries in each page, So I don't want to use prepared statements. Don't suggest prepared statements.
I am aware of PDO, but I will use MySQL only, so I'm better with MySQLi. So please don't suggest PDO.




class Dbquery extends MySQLi
{
    public $host,$user,$password,$database,$connection;
    public function __construct($host,$user,$password,$database)
    {
        $this -&gt; host = $host;
        $this -&gt; user = $user;
        $this -&gt; password = $password;
        $this -&gt; database = $database;
        $this -&gt; connect_me();
    }
    private function connect_me()
    {
        $this -&gt; connection = $this-&gt; connect($this-&gt;host,$this-&gt;user,$this-&gt;password,$this-&gt;database);
        if( $this -&gt; connect_error )
            die($this-&gt;connect_error);
    }
    private function extracts($data) // function used to append data and column names for insert query
    {
        $column = array("","");
        foreach ($data as $index =&gt; $details)
        {
            $column[0].= $index.",";
            $column[1].= "'".$this -&gt;real_escape_string($details)."',";
        }
        $column[0] = rtrim($column[0],",");
        $column[1] = rtrim($column[1],",");
        return $column;
    }
    private function append($data) // function used to append data and column names for update query
    {
        $string = "";
        foreach($data as $index =&gt; $details)
        {
            $string.= $index."='".$this -&gt; real_escape_string($details)."',";
        }
        $string = rtrim($string,",");
        return $string;
    }
    public function insert($table,$data)
    {
        $extracted = $this -&gt; extracts($data);
        $this -&gt; query("INSERT INTO ".$table." (".$extracted[0].") VALUES(".$extracted[1].")");
        if($this -&gt; error)
            return $this -&gt; error;
        else
            return $this -&gt; insert_id;
    }
    public function update($table,$data,$where)
    {
        $extracted = $this -&gt; append($data);
        $this -&gt; query("UPDATE ".$table." SET ".$extracted." WHERE ".$where);
        if($this -&gt; error)
            return $this -&gt; error;
    }
    public function select($table,$column = "",$where = 1,$orderby = "",$limit = "")
    {
        if($column == "")
            $column='*';
        if($orderby == "")
            $orderby = 'NULL';
        if($limit != "")
        {
            $limit = "LIMIT ".$limit;
        }
        $result = $this -&gt; query("SELECT ".$column." FROM ".$table." WHERE ".$where." ORDER BY ".$orderby."".$limit."");
        if($this -&gt; error)
        {
            return $this -&gt; error;
        }
        else
        {
            $index = 0;
            while($row = $result -&gt; fetch_assoc())
            {
                $data[$index] = $row;
            }
            return $data;
        }
    }
    public function delete($table,$where)
    {
        $this -&gt; query("DELETE FROM ".$table." WHERE ".$where."");
        if($this -&gt; error)
        {
            return $this -&gt; error;
        }
        else
        {
            return true;
        }
    }
}
Note: I don't think this is what you want to hear. But I have to write &quot;the truth&quot;. This is my personal opinions about your code.
Give me parameterized SQL or give me death!

tell me if there are any bugs or improvements to be made.



Don't suggest prepared statements.

I'm sorry, but those two requests really don't fit together in the same Code Review question.
I understand what you're doing here, and it's nice that you're doing it for learning purposes. It's nice to be able to extend the mysqli class in PHP.
However, I wouldn't recommend using the methods you have in this class. As you say:

I'm expecting very different queries in each page

Consider then: What functionality does this class provide you with? How much code does it save for you? Will it make your code more readable?
As I see it, there are primarily four lines that summarize what your class is all about:
$this -&gt; query(&quot;INSERT INTO &quot;.$table.&quot; (&quot;.$extracted[0].&quot;) VALUES(&quot;.$extracted[1].&quot;)&quot;);
$this -&gt; query(&quot;UPDATE &quot;.$table.&quot; SET &quot;.$extracted.&quot; WHERE &quot;.$where);
$result = $this -&gt; query(&quot;SELECT &quot;.$column.&quot; FROM &quot;.$table.&quot; WHERE &quot;.$where.&quot; ORDER BY &quot;.$orderby.&quot;&quot;.$limit.&quot;&quot;);
$this -&gt; query(&quot;DELETE FROM &quot;.$table.&quot; WHERE &quot;.$where.&quot;&quot;);

That is, you're essentially making it a little &quot;easier&quot; to write the SQL queries.
In your comment you ask if you can run different queries each time using prepared statements, and if you can use joins and stuff. The answer to these questions is: YES! Is it efficient? YES!. We're often talking milliseconds of difference between prepared statements and non-prepared statements (except when you perform the same prepared statement multiple times with different parameters, in which a prepared statement performs significantly faster!). If you are worried about the speed of prepared statements, don't be. They're fast. If they're slow, then there's something wrong with your database structure or your query, not with the fact that you're using prepared statements.
Here is what I personally think:

Other developers reading your code will be confused as they are not familiar with your Dbquery class
By not using your class you will be more experienced with writing SQL statements, it will probably go faster writing the SQL statements than you think.
Your class does not provide that much functionality. In fact, it can act as a restriction as writing something like select(&quot;mytable LEFT JOIN table2 ON (mytable.a = table2.b)&quot;, &quot;table2.c, mytable.a&quot;, &quot;mytable.a &gt; 4&quot;, &quot;table2.c&quot;, 5) just feels completely strange, wrong, and hard to remember what the parameters are, and you'll likely end up trying to reconstruct the resulting SQL query in your mind anyway (or is that just me?)

The point I'm trying to make here is: If you expect &quot;very different queries in each page&quot;, then write those queries in each page. As long as they're not entirely dynamic queries, use prepared statements! Prepared statements are the way to go in the &quot;real&quot; PHP world.

I am aware of PDO, but I will use MySQL only, so I'm better with MySQLi. So please don't suggest PDO.

Sure, I have nothing against MySQLi myself. That's also what I tend to use when working in PHP. I think the choice of PDO vs. mySQLi is mostly opinion-based. The main advantage of PDO is that it can work with other databases except mySQL, but as you will use mySQL only, it's perfectly fine in my opinion to use mySQLi. At least you're not using the old mySQL functions!