i have one function which calculate total number of records in table and get two arguments and both are optional.
function getTotal($id=0,$id1=0)
{
($id==0?$addQuery="":$addQuery=" where art_id=".$id);
if($id1<>0 && $id==0)
{
$addQuery=" where up_type=".$id1
}
if($id1<>0 && $id<>0)
{
$addQuery=" and up_type=".$id1
}
mysql_set_charset('utf8');
$query="SELECT COUNT(id) FROM tbl_up ".$addQuery;
$result=$this->query($query,1);
return $result;
}
if you see i write if id is passed then i put the where class in one line
but if 2nd argument id1 is passed or not i need to add text to where class, but here is if id is passed then it should start from and and if id is not passed it should start with where
i try to write if but these lines are too much, i need some thing like first line
($id==0?$addQuery="":$addQuery=" where art_id=".$id);
for 2nd agrument.
Thanks