Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Select All Data From MySql Database Table PHP Function

//Select All Functions
// $inner=ArrayValue ex:array('factor'=>array('usr_id','fac_user_id'));
// $where,$groupBy,$orderBy=String Value
// $table=string & array ex: "users", array("user_id,cat_uid"=>'users')
//getTableInfo('roles')[0];
//$persondetail = $db->get_row("$qry");
//
//getTableInfo('roles');
//$persondetail = $db->get_results("$qry");
function getTableInfo($table, $where = '', $inner = '', $groupBy = '', $orderBy = '')
{
    global $db;
    $groupByStr = ($groupBy) ? 'GROUP BY ' : '';
    $orderByStr = ($orderBy) ? 'ORDER BY ' : '';
    if (!is_array($table)) {
        $qry = "SELECT * FROM $table ";
    } else {
        foreach ($table as $key => $value) {
            $qry = "SELECT $key FROM $value ";
        }
    }

     if ($inner) {
        $i = 0;
        foreach ($inner as $key1 => $level1) {
            $qry .= " INNER JOIN " . $key1 . " ON ";

            for ($i = 0; $i < 2; $i++) {
                $qry .= $level1[$i];
                if ($i == 0)
                    $qry .= " = ";
            }

        }
    }
  if ($where) {
        $qry .= ' WHERE ' . $where . ' ' . $groupByStr . $groupBy . ' ' . $orderByStr . $orderBy;
    } else {
        $qry .= ' ' . $groupByStr . $groupBy . ' ' . $orderByStr . $orderBy;
    }

    $information = $db->get_results("$qry");

    if ($information)
        return $information;
    else
        return false;
}
Comment

PREVIOUS NEXT
Code Example
Php :: remove ul container from wp_nav_menu 
Php :: $usr= $_POST["user"]; $pswd= $_POST["pass"]; 
Php :: display PHP errors based on environment variable 
Php :: how to get many of quensation php programming language 
Php :: union for rwos 
Php :: Dorf SMS Plugin 
Php :: pass in value in route group middle ware 
Php :: list database table rows plugin wordpress 
Php :: php refresh_ttl 
Php :: custome route to a page with dynamic parameters wordpress 
Php :: installing php storm version 20 in ubuntu 
Php :: Laravel array to string error 
Php :: eloquent search from child table column 
Php :: customize+forgot+password+laravel 
Php :: Laravel retrieving aggregates 
Php :: PHP OOP - Class Constants 
Php :: laravel eloquent order by relationship 
Php :: php pdo memory exhausted 
Php :: how to get last 10 digit from number in php 
Php :: Accept multiple space separated inputs 
Php :: termii curl otp 
Php :: laravel Relations transform 
Php :: yii2 gridview get selected rows 
Php :: Store authentication status in a cookies 
Php :: wp cpt dashicon 
Php :: add tag tpo protfolio? 
Php :: live search in ajax 
Php :: php script 
Php :: read an email with php 
Php :: undefined reference to 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =