/** * @param $field_name if object exists with this name, then update that item */ public static function store($obj, $tblname, $field_name = 'id') { if ($obj->{$field_name} && SqlObject::idExists($obj->{$field_name}, $tblname, $field_name)) { // throw new \Exception ('obj fieldname: '.$obj->$field_name.' tbl '.$tblname); SqlObject::updateId($obj, $tblname, $field_name); return $obj->{$field_name}; } return SqlObject::create($obj, $tblname); }