so i want update if exist this id on table else i want to insert add the data .
Thanks in advance
Code:
public function addUpdateCust(array $data)
{
if(!empty($data))
{
if($this->update($data, array('id = ?' => $data['id'])) > 0 )
{
return true;
}
$row = $this->createRow();
//$row->id = $data['id'];
$row->code = $data['code'];
$row->fabname = $data['fabname'];
$row->namecustomer = $data['namecustomer'];
$row->adresse = $data['adresse'];
$row->city = $data['city'];
$row->zipcode = $data['zipcode'];
$row->country = $data['country'];
$row->phone = $data['phone'];
$row->representative = $data['representative'];
$row->idUser = NULL;
//var_dump($row);
try {
return $row->save();
} catch (Exception $e) {
return $e;
}
}
return false;
}
Comment