Mysql 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.

Function Reference :
       			resource/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 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 in which where condition given in form of associative array. array("gender"=>"male")


            $sdb= new SimplifiedDB(); 


Returns mysql result set by default. You can set $sdb->output_array=true, to return array as output.
If you use print_r($row) in
while($row = mysql_fetch_array($result)) {
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`='male'
$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 'in' claues					

            // Example of using 'not in' clause
            // Example of using 'group by ' and 'having'					
              $sdb->having="sum(visits)>10 ";