php - Return values for appropriate arguments -
is here possible write single return both $strvalues , $strthumbimages need return $strvalues every time returning $strthumbimages when available..
function doselectbranchrecords($objarray,$imageid = null) { global $global_config; $strwhereclause = ''; if ($objarray['frmnamesearch']) { $strwhereclause.= " , a.branch_ident = '".$objarray['frmnamesearch']."' "; } if ($objarray['frmloansearch']) { $strwhereclause.= " , a.loan_ident = '".$objarray['frmloansearch']."' "; } if ($objarray['frmbeneficiarysearch']) { $strwhereclause.= " , a.beneficiary_idents = '".$objarray['frmbeneficiarysearch']."' "; } if ($objarray['frmdatesearch']) { $strdate = explode("-", $objarray['frmdatesearch']); $straccountstarted = $strdate[2].'-'.$strdate[1].'-'.$strdate[0]; $strwhereclause.= " , a.account_started = '".$straccountstarted."' "; /*printarray($strwhereclause); exit;*/ } if ($imageid) { $strthumbimages = $global_config["siteglobaluploadpath"].$imageid; return $strthumbimages; } $strsqlselect = "select a.*,b.branch_name tbl_companydetails a,tbl_branchdetails b a.branch_ident=b.branch_id $strwhereclause order company_id desc"; $strvalues = selectqry($strsqlselect); return $strvalues; }
@simon , @suchit right in cannot return more 1 variable. in php straightforwarded return list multiple items so:
function getxyz(){ return array(4,5,6); } list($x,$y,$z) = getxyz();
so in case so:
$strthumbimages = null; if ($imageid) { $strthumbimages = $global_config["siteglobaluploadpath"].$imageid; } $strsqlselect = "select a.*,b.branch_name tbl_companydetails a,tbl_branchdetails b a.branch_ident=b.branch_id $strwhereclause order company_id desc"; $strvalues = selectqry($strsqlselect); return array($strvalues, $strthumbimages);
Comments
Post a Comment