How to write helper class for different select operation? <p>Guys i want different "select" operation as per my needs, but i just need one helper function for all select operation , How do i get it??</p> <p>This is my helper class Database.php</p> <pre><code>&lt;?php class Database { public $server = "localhost"; public $user = "root"; public $password = ""; public $database_name = "employee_application"; public $table_name = ""; public $database_connection = ""; public $class_name = "Database"; public $function_name = ""; //constructor public function __construct(){ //establishes connection to database $this-&gt;database_connection = new mysqli($this-&gt;server, $this-&gt;user, $this-&gt;password, $this-&gt;database_name); if($this-&gt;database_connection-&gt;connect_error) die ("Connection failed".$this-&gt;database_connection-&gt;connect_error); } //destructor public function __destruct(){ //closes database connection if(mysqli_close($this-&gt;database_connection)) { $this-&gt;database_connection = null; } else echo "couldn't close"; } public function run_query($sql_query) { $this-&gt;function_name = "run_query"; try{ if($this-&gt;database_connection){ $output = $this-&gt;database_connection-&gt;query($sql_query); if($output){ $result["status"] = 1; $result["array"] = $output; } else{ $result["status"] = 0; $result["message"] = "Syntax error in query"; } } else{ throw new Exception ("Database connection error"); } } catch (Exception $error){ $result["status"] = 0; $result["message"] = $error-&gt;getMessage(); $this-&gt;error_table($this-&gt;class_name, $this-&gt;function_name, "connection error", date('Y-m-d H:i:s')); } return $result; } public function get_table($start_from, $per_page){ $this-&gt;function_name = "get_table"; $sql_query = "select * from $this-&gt;table_name LIMIT $start_from, $per_page"; return $this-&gt;run_query($sql_query); } } ?&gt; </code></pre> <p>In the above code get_table function performs basic select operation.... Now i want get_table function to perform all this below operations,</p> <pre><code>$sql_query = "select e.id, e.employee_name, e.salary, dept.department_name, desi.designation_name, e.department, e.designation from employees e LEFT OUTER JOIN designations desi ON e.designation = desi.id LEFT OUTER JOIN departments dept ON e.department = dept.id ORDER BY e.employee_name LIMIT $start_from, $per_page"; $sql_query = "select id, designation_name from designations ORDER BY designation_name"; $sql_query = "select * from departments"; $sql_query = "select * from departments Limit 15,10"; </code></pre> <p>So how to overcome this issue, can anyone help me out?</p>