//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;
}