
Binny V A
By: a guest on Mar 21st, 2009 | syntax:
PHP | size: 1.52 KB | hits: 276 | expires: Never
/**
* @author hussein
* @copyright 2009
*/
//$args = array("table" => array("field1", "field2", "field3"));
$args = array("table1" => "field1",
"table2" => array("field1", "field2", "field3"),
"table3" => "field",
"table4" => "field",
"table5" => array("fiel1", "fiel2", "fiel3"),
"table6" => "field2",
"table7" => "field",
"table8" => "field");
//$args = "not array";
echo s($args);
//echo count($args);
function s($vars, $where=''){
$where = " WHERE ".$where;
}
foreach($vars as $table => $fields){
$t = substr($table, "0", "2").$x;
$t_arr[] = $table." AS ".$t;
foreach($fields as $field){
$f_arr[] .= $t.".".$field;
}
$x++;
continue;
}
$f_arr[] = $t.".".$fields;
$x++;
}
return $qry = "SELECT ".$f_str." FROM ".$t_str.$where;
}
}elseif(count($vars) == 1
){
foreach($vars as $table => $fields){
$qry = "SELECT ".$fields." FROM ".$table.$where;
}
$fields_str = implode(", ", $fields);
$qry = "SELECT ".$fields_str." FROM ".$table.$where;
}
}
}else{
$qry = "An undefined error occured!";
}
return $qry;
}else{
$error = "Is not an array!";
return $error;
}
}