Mysqli Select Operation


Select records from the single table. You can provide columns to be selected and where clause with associative array of conditions with keys as columns and value as column value. Along with these function parameters, you can set group by columnname, order by columnname, limit, like, in , not in, between clause etc. This function will automatically creates query for you and select data.

You may need to set $parameter_types as data type of where condition columns before using this function. For examples if you have five columns then you need to pass data type of each column like "sssis" where s denotes the string data type, i denotes numeric data type.

Function Reference :
       			mysqli_result/array dbSelect(string $table_name [, array $columns=array()] [, assoc. array $select_where_condition=array()]) 


Name Type Required Parameter Info Example
table_name string Yes The name of the table to select records. any table name like employee_table,user_table
columns array Optional Array of columns to be selected array("username","gender")
select_where_condition associative array Optional Associative array with key as column name and values as column value for where clause. array("gender"=>"male")


         $sdb= new SimplifiedDB(); 


Returns result object by default. You can set $sdb->output_array=true, to return array as output.
If you use print_r($row) in
while ($rows = $result->fetch_array()) {
it will show output as in following format.

Array ( [0] => Ram [firstName] => Ram [1] => [email] => ) Array ( [0] => Sachine [firstName] => Sachine [1] => [email] => )


Debug Operation Result/Output
$sdb->query SELECT `firstName`,`email` FROM `users` WHERE `gender`=?
$sdb->message_info Connected to database

More Examples

           // Most basic example, selecting all columns and rows of table 'users'
           //selecting all columns of table 'users' where gender='male'
           // Applying group by, order by and limit conditions
           // Example of using != operator, similary you can use any valid operator like '>','<','>=','<=',
            $result=$sdb->dbSelect("users",array("firstName","email"),array("gender !="=>"male"));
           // Example of using 'like'
           // Example of using 'or' instead of 'and' in where condition
           // Example of using count(*), you needs to make backticks(`)="" off to use that.
           // Example of using Max, you needs to make backticks(`)="" off to use that.
            // Example of using between keyword
           // Example of using 'in' claues
           // Example of using 'not in' clause
           // Example of using 'group by ' and 'having'
            $sdb->having="sum(visits)>10 ";