public static function edit($vars, $files) { $db = DB::get(); $row = $db->prepare("UPDATE empresas SET name = :name , img = :img WHERE id = :id"); $row->bindParam(':name', $vars["nombre"], PDO::PARAM_STR); $row->bindParam(':img', !empty($files["empresa"]["name"]) ? $files["empresa"]["name"] : $vars["old-image"], PDO::PARAM_STR); $row->bindParam(':id', $vars["empresa-id"], PDO::PARAM_STR); $tmp_filename = $files["empresa"]["tmp_name"]; $dir = "../resources/images/"; if ($row->execute()) { if (!empty($files["empresa"]["name"])) { move_uploaded_file($tmp_filename, $dir . $files["empresa"]["name"]); } self::$success = "Empresa guardada correctamente"; } }